mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-17 20:10:50 +01:00
Miglioramenti minori
This commit is contained in:
parent
dea2d1dbdc
commit
6281995a94
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
include_once __DIR__.'/core.php';
|
include_once __DIR__.'/core.php';
|
||||||
|
|
||||||
use Models\Checklist;
|
use Models\Checklist\Check;
|
||||||
use Models\Note;
|
use Models\Note;
|
||||||
use Models\User;
|
use Models\User;
|
||||||
|
|
||||||
@ -124,13 +124,13 @@ elseif (filter('op') == 'add_check') {
|
|||||||
|
|
||||||
$assigned_user = User::find(post('assigned_user'));
|
$assigned_user = User::find(post('assigned_user'));
|
||||||
|
|
||||||
$check = Checklist::build($user, $assigned_user, $structure, $id_record, $content, $parent_id);
|
$check = Check::build($user, $assigned_user, $structure, $id_record, $content, $parent_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rimozione checklist
|
// Rimozione checklist
|
||||||
elseif (filter('op') == 'delete_check') {
|
elseif (filter('op') == 'delete_check') {
|
||||||
$check_id = post('check_id');
|
$check_id = post('check_id');
|
||||||
$check = Checklist::find($check_id);
|
$check = Check::find($check_id);
|
||||||
|
|
||||||
$check->delete();
|
$check->delete();
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ elseif (filter('op') == 'delete_check') {
|
|||||||
// Gestione check per le checklist
|
// Gestione check per le checklist
|
||||||
elseif (filter('op') == 'toggle_check') {
|
elseif (filter('op') == 'toggle_check') {
|
||||||
$check_id = post('check_id');
|
$check_id = post('check_id');
|
||||||
$check = Checklist::find($check_id);
|
$check = Check::find($check_id);
|
||||||
|
|
||||||
if (!empty($check)) {
|
if (!empty($check)) {
|
||||||
$check->checked_at = $check->checked_at ? null : date('Y-m-d H:i:s');
|
$check->checked_at = $check->checked_at ? null : date('Y-m-d H:i:s');
|
||||||
|
@ -234,7 +234,7 @@ echo '
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script src="'.$rootdir.'/lib/functions.js"></script>
|
<script src="'.$rootdir.'/lib/functions.js"></script>
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
|
||||||
include_once App::filepath('include|custom|', 'bottom.php');
|
include_once App::filepath('include|custom|', 'bottom.php');
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ echo '
|
|||||||
|
|
||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
echo '<<script>$(document).ready(init)</script>';
|
echo '<script>$(document).ready(init)</script>';
|
||||||
echo '<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">';
|
echo '<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -44,7 +44,7 @@ echo '
|
|||||||
|
|
||||||
$file = basename(__FILE__);
|
$file = basename(__FILE__);
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var content = $("#righe_documento");
|
var content = $("#righe_documento");
|
||||||
|
@ -47,7 +47,7 @@ echo '
|
|||||||
|
|
||||||
$file = basename(__FILE__);
|
$file = basename(__FILE__);
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var content = $("#righe_documento");
|
var content = $("#righe_documento");
|
||||||
|
@ -45,7 +45,7 @@ echo '
|
|||||||
|
|
||||||
$file = basename(__FILE__);
|
$file = basename(__FILE__);
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var content = $("#righe_documento");
|
var content = $("#righe_documento");
|
||||||
|
@ -45,7 +45,7 @@ echo '
|
|||||||
|
|
||||||
$file = basename(__FILE__);
|
$file = basename(__FILE__);
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var content = $("#righe_documento");
|
var content = $("#righe_documento");
|
||||||
|
@ -46,7 +46,7 @@ echo '
|
|||||||
|
|
||||||
$file = basename(__FILE__);
|
$file = basename(__FILE__);
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var content = $("#righe_documento");
|
var content = $("#righe_documento");
|
||||||
|
@ -109,7 +109,7 @@ echo '
|
|||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -133,4 +133,4 @@ if ($show_prezzi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
@ -221,7 +221,7 @@ if (!$is_completato) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>
|
<script>$(document).ready(init)</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){';
|
$(document).ready(function(){';
|
||||||
|
@ -96,7 +96,7 @@ echo '
|
|||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
|
@ -28,4 +28,4 @@ echo '
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
@ -91,4 +91,4 @@ function submitCheck() {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
@ -107,7 +107,7 @@ echo '
|
|||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -233,7 +233,7 @@ echo '
|
|||||||
</form>';
|
</form>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<<script>$(document).ready(init)</script>';
|
<script>$(document).ready(init)</script>';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script>
|
<script>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace HTMLBuilder\Manager;
|
namespace HTMLBuilder\Manager;
|
||||||
|
|
||||||
use Models\Checklist;
|
use Models\Checklist\Check;
|
||||||
use Modules;
|
use Modules;
|
||||||
use Plugins;
|
use Plugins;
|
||||||
|
|
||||||
@ -29,10 +29,10 @@ class ChecklistManager implements ManagerInterface
|
|||||||
|
|
||||||
// ID del form
|
// ID del form
|
||||||
$manager_id = 'checklist_'.$options['id_module'].'_'.$options['id_plugin'];
|
$manager_id = 'checklist_'.$options['id_module'].'_'.$options['id_plugin'];
|
||||||
$checklists = $structure->checklists($options['id_record']);
|
$checks = $structure->checks($options['id_record']);
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
foreach ($checklists as $checklist) {
|
foreach ($checks as $checklist) {
|
||||||
$list[] = [
|
$list[] = [
|
||||||
'id' => $checklist->id,
|
'id' => $checklist->id,
|
||||||
'text' => $checklist->content,
|
'text' => $checklist->content,
|
||||||
@ -77,7 +77,7 @@ class ChecklistManager implements ManagerInterface
|
|||||||
$result .= '
|
$result .= '
|
||||||
<ul class="checklist">';
|
<ul class="checklist">';
|
||||||
|
|
||||||
foreach ($checklists as $checklist) {
|
foreach ($checks as $checklist) {
|
||||||
$result .= $this->renderChecklist($checklist);
|
$result .= $this->renderChecklist($checklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ function reload_'.$manager_id.'() {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function renderChecklist(Checklist $checklist, $level = 0)
|
protected function renderChecklist(Check $checklist, $level = 0)
|
||||||
{
|
{
|
||||||
$result = '
|
$result = '
|
||||||
<li id="check_'.$checklist->id.'" class="check-item'.(!empty($checklist->checked_at) ? ' checked' : '').'">
|
<li id="check_'.$checklist->id.'" class="check-item'.(!empty($checklist->checked_at) ? ' checked' : '').'">
|
||||||
|
74
src/Models/Checklist/Check.php
Normal file
74
src/Models/Checklist/Check.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Models\Checklist;
|
||||||
|
|
||||||
|
use Common\Model;
|
||||||
|
use Traits\Components\ChecklistTrait;
|
||||||
|
use Traits\HierarchyTrait;
|
||||||
|
use Models\User;
|
||||||
|
use Models\Module;
|
||||||
|
use Models\Plugin;
|
||||||
|
|
||||||
|
class Check extends Model
|
||||||
|
{
|
||||||
|
use HierarchyTrait;
|
||||||
|
|
||||||
|
protected static $parent_identifier = 'id_parent';
|
||||||
|
protected $table = 'zz_checks';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea un nuovo elemento della checklist.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @param User $assigned_user
|
||||||
|
* @param ChecklistTrait $structure
|
||||||
|
* @param int $id_record
|
||||||
|
* @param string $contenuto
|
||||||
|
* @param int $id_parent
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(User $user, User $assigned_user, $structure, $id_record, $contenuto, $id_parent = null)
|
||||||
|
{
|
||||||
|
$model = parent::build();
|
||||||
|
|
||||||
|
$model->user()->associate($user);
|
||||||
|
$model->assignedUser()->associate($assigned_user);
|
||||||
|
|
||||||
|
if ($structure instanceof Module) {
|
||||||
|
$model->module()->associate($structure);
|
||||||
|
} elseif ($structure instanceof Plugin) {
|
||||||
|
$model->plugin()->associate($structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->id_record = $id_record;
|
||||||
|
$model->id_parent = $id_parent;
|
||||||
|
$model->content = $contenuto;
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Relazioni Eloquent */
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'id_utente');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assignedUser()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'id_utente_assegnato');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plugin()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plugin::class, 'id_plugin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function module()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Module::class, 'id_module');
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Models;
|
namespace Models\Checklist;
|
||||||
|
|
||||||
use Common\Model;
|
use Common\Model;
|
||||||
use Traits\HierarchyTrait;
|
use Traits\Components\ChecklistTrait;
|
||||||
use Traits\NoteTrait;
|
use Traits\NoteTrait;
|
||||||
|
|
||||||
class Checklist extends Model
|
class Checklist extends Model
|
||||||
{
|
{
|
||||||
use HierarchyTrait;
|
|
||||||
|
|
||||||
protected static $parent_identifier = 'id_parent';
|
|
||||||
protected $table = 'zz_checklists';
|
protected $table = 'zz_checklists';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea un nuovo elemento della checklist.
|
* Crea un nuovo elemento della checklist.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param ChecklistTrait $structure
|
||||||
* @param User $assigned_user
|
|
||||||
* @param NoteTrait $structure
|
|
||||||
* @param int $id_record
|
* @param int $id_record
|
||||||
* @param string $contenuto
|
* @param string $contenuto
|
||||||
* @param int $id_parent
|
* @param int $id_parent
|
43
src/Models/Checklist/ChecklistItem.php
Normal file
43
src/Models/Checklist/ChecklistItem.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Models\Checklist;
|
||||||
|
|
||||||
|
use Common\Model;
|
||||||
|
use Traits\HierarchyTrait;
|
||||||
|
|
||||||
|
class Checklist extends Model
|
||||||
|
{
|
||||||
|
use HierarchyTrait;
|
||||||
|
|
||||||
|
protected static $parent_identifier = 'id_parent';
|
||||||
|
protected $table = 'zz_checklist_items';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crea un nuovo elemento della checklist.
|
||||||
|
*
|
||||||
|
* @param Checklist $checklist
|
||||||
|
* @param string $contenuto
|
||||||
|
* @param int $id_parent
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public static function build(Checklist $checklist, $contenuto, $id_parent = null)
|
||||||
|
{
|
||||||
|
$model = parent::build();
|
||||||
|
|
||||||
|
$model->checklist()->associate($checklist);
|
||||||
|
$model->id_parent = $id_parent;
|
||||||
|
$model->content = $contenuto;
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Relazioni Eloquent */
|
||||||
|
|
||||||
|
public function checklist()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Checklist::class, 'id_checklist');
|
||||||
|
}
|
||||||
|
}
|
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
namespace Traits\Components;
|
namespace Traits\Components;
|
||||||
|
|
||||||
use Models\Checklist;
|
use Models\Checklist\Check;
|
||||||
|
use Models\Checklist\Checklist;
|
||||||
|
|
||||||
trait ChecklistTrait
|
trait ChecklistTrait
|
||||||
{
|
{
|
||||||
public function checklists($id_record)
|
public function checks($id_record)
|
||||||
{
|
{
|
||||||
return $this->hasMany(Checklist::class, $this->component_identifier)->where('id_record', $id_record)->whereNull('id_parent')->orderBy('created_at')->get();
|
return $this->hasMany(Check::class, $this->component_identifier)->where('id_record', $id_record)->whereNull('id_parent')->orderBy('created_at')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checklists()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Checklist::class, $this->component_identifier)->orderBy('created_at')->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,14 +205,14 @@ CREATE TABLE IF NOT EXISTS `zz_notes` (
|
|||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
-- Sistema di checklists
|
-- Sistema di checklists
|
||||||
CREATE TABLE IF NOT EXISTS `zz_checklists` (
|
CREATE TABLE IF NOT EXISTS `zz_checks` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`id_module` int(11),
|
`id_module` int(11),
|
||||||
`id_plugin` int(11),
|
`id_plugin` int(11),
|
||||||
`id_record` int(11) NOT NULL,
|
`id_record` int(11) NOT NULL,
|
||||||
`id_utente` int(11) NOT NULL,
|
`id_utente` int(11) NOT NULL,
|
||||||
`id_utente_assegnato` int(11) NOT NULL,
|
`id_utente_assegnato` int(11) NOT NULL,
|
||||||
`checked_at` TIMESTAMP,
|
`checked_at` TIMESTAMP NULL,
|
||||||
`content` TEXT,
|
`content` TEXT,
|
||||||
`id_parent` int(11),
|
`id_parent` int(11),
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
@ -220,18 +220,25 @@ CREATE TABLE IF NOT EXISTS `zz_checklists` (
|
|||||||
FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE,
|
FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE,
|
FOREIGN KEY (`id_utente`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`id_utente_assegnato`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE,
|
FOREIGN KEY (`id_utente_assegnato`) REFERENCES `zz_users`(`id`) ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`id_parent`) REFERENCES `zz_checklists`(`id`) ON DELETE CASCADE
|
FOREIGN KEY (`id_parent`) REFERENCES `zz_checks`(`id`) ON DELETE CASCADE
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `zz_checklist_templates` (
|
CREATE TABLE IF NOT EXISTS `zz_checklists` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255),
|
||||||
`id_module` int(11),
|
`id_module` int(11),
|
||||||
`id_plugin` int(11),
|
`id_plugin` int(11),
|
||||||
`id_record` int(11) NOT NULL,
|
PRIMARY KEY (`id`),
|
||||||
|
FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `zz_checklist_items` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_checklist` int(11),
|
||||||
`content` TEXT,
|
`content` TEXT,
|
||||||
`id_parent` int(11),
|
`id_parent` int(11),
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
FOREIGN KEY (`id_module`) REFERENCES `zz_modules`(`id`) ON DELETE CASCADE,
|
FOREIGN KEY (`id_checklist`) REFERENCES `zz_checklists`(`id`) ON DELETE CASCADE,
|
||||||
FOREIGN KEY (`id_plugin`) REFERENCES `zz_plugins`(`id`) ON DELETE CASCADE,
|
FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_items`(`id`) ON DELETE CASCADE
|
||||||
FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_templates`(`id`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user