Miglioramenti minori
This commit is contained in:
parent
dea2d1dbdc
commit
6281995a94
|
@ -2,7 +2,7 @@
|
|||
|
||||
include_once __DIR__.'/core.php';
|
||||
|
||||
use Models\Checklist;
|
||||
use Models\Checklist\Check;
|
||||
use Models\Note;
|
||||
use Models\User;
|
||||
|
||||
|
@ -124,13 +124,13 @@ elseif (filter('op') == 'add_check') {
|
|||
|
||||
$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
|
||||
elseif (filter('op') == 'delete_check') {
|
||||
$check_id = post('check_id');
|
||||
$check = Checklist::find($check_id);
|
||||
$check = Check::find($check_id);
|
||||
|
||||
$check->delete();
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ elseif (filter('op') == 'delete_check') {
|
|||
// Gestione check per le checklist
|
||||
elseif (filter('op') == 'toggle_check') {
|
||||
$check_id = post('check_id');
|
||||
$check = Checklist::find($check_id);
|
||||
$check = Check::find($check_id);
|
||||
|
||||
if (!empty($check)) {
|
||||
$check->checked_at = $check->checked_at ? null : date('Y-m-d H:i:s');
|
||||
|
|
|
@ -234,7 +234,7 @@ echo '
|
|||
});
|
||||
</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');
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ echo '
|
|||
|
||||
</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">';
|
||||
|
||||
?>
|
||||
|
|
|
@ -44,7 +44,7 @@ echo '
|
|||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
|
|
@ -47,7 +47,7 @@ echo '
|
|||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
|
|
@ -45,7 +45,7 @@ echo '
|
|||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
|
|
@ -45,7 +45,7 @@ echo '
|
|||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
|
|
@ -46,7 +46,7 @@ echo '
|
|||
|
||||
$file = basename(__FILE__);
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script>
|
||||
var content = $("#righe_documento");
|
||||
|
|
|
@ -109,7 +109,7 @@ echo '
|
|||
</form>';
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -133,4 +133,4 @@ if ($show_prezzi) {
|
|||
}
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
|
|
@ -221,7 +221,7 @@ if (!$is_completato) {
|
|||
}
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>
|
||||
<script>$(document).ready(init)</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){';
|
||||
|
|
|
@ -96,7 +96,7 @@ echo '
|
|||
</form>';
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
|
|
|
@ -28,4 +28,4 @@ echo '
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
|
|
@ -91,4 +91,4 @@ function submitCheck() {
|
|||
}
|
||||
</script>
|
||||
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
|
|
@ -107,7 +107,7 @@ echo '
|
|||
</form>';
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -233,7 +233,7 @@ echo '
|
|||
</form>';
|
||||
|
||||
echo '
|
||||
<<script>$(document).ready(init)</script>';
|
||||
<script>$(document).ready(init)</script>';
|
||||
|
||||
echo '
|
||||
<script>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace HTMLBuilder\Manager;
|
||||
|
||||
use Models\Checklist;
|
||||
use Models\Checklist\Check;
|
||||
use Modules;
|
||||
use Plugins;
|
||||
|
||||
|
@ -29,10 +29,10 @@ class ChecklistManager implements ManagerInterface
|
|||
|
||||
// ID del form
|
||||
$manager_id = 'checklist_'.$options['id_module'].'_'.$options['id_plugin'];
|
||||
$checklists = $structure->checklists($options['id_record']);
|
||||
$checks = $structure->checks($options['id_record']);
|
||||
|
||||
$list = [];
|
||||
foreach ($checklists as $checklist) {
|
||||
foreach ($checks as $checklist) {
|
||||
$list[] = [
|
||||
'id' => $checklist->id,
|
||||
'text' => $checklist->content,
|
||||
|
@ -77,7 +77,7 @@ class ChecklistManager implements ManagerInterface
|
|||
$result .= '
|
||||
<ul class="checklist">';
|
||||
|
||||
foreach ($checklists as $checklist) {
|
||||
foreach ($checks as $checklist) {
|
||||
$result .= $this->renderChecklist($checklist);
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ function reload_'.$manager_id.'() {
|
|||
return $result;
|
||||
}
|
||||
|
||||
protected function renderChecklist(Checklist $checklist, $level = 0)
|
||||
protected function renderChecklist(Check $checklist, $level = 0)
|
||||
{
|
||||
$result = '
|
||||
<li id="check_'.$checklist->id.'" class="check-item'.(!empty($checklist->checked_at) ? ' checked' : '').'">
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Models;
|
||||
namespace Models\Checklist;
|
||||
|
||||
use Common\Model;
|
||||
use Traits\Components\ChecklistTrait;
|
||||
use Traits\HierarchyTrait;
|
||||
use Traits\NoteTrait;
|
||||
use Models\User;
|
||||
use Models\Module;
|
||||
use Models\Plugin;
|
||||
|
||||
class Checklist extends Model
|
||||
class Check extends Model
|
||||
{
|
||||
use HierarchyTrait;
|
||||
|
||||
protected static $parent_identifier = 'id_parent';
|
||||
protected $table = 'zz_checklists';
|
||||
protected $table = 'zz_checks';
|
||||
|
||||
/**
|
||||
* Crea un nuovo elemento della checklist.
|
||||
*
|
||||
* @param User $user
|
||||
* @param User $assigned_user
|
||||
* @param NoteTrait $structure
|
||||
* @param ChecklistTrait $structure
|
||||
* @param int $id_record
|
||||
* @param string $contenuto
|
||||
* @param int $id_parent
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Models\Checklist;
|
||||
|
||||
use Common\Model;
|
||||
use Traits\Components\ChecklistTrait;
|
||||
use Traits\NoteTrait;
|
||||
|
||||
class Checklist extends Model
|
||||
{
|
||||
protected $table = 'zz_checklists';
|
||||
|
||||
/**
|
||||
* Crea un nuovo elemento della checklist.
|
||||
*
|
||||
* @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');
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
use Models\Checklist;
|
||||
use Models\Checklist\Check;
|
||||
use Models\Checklist\Checklist;
|
||||
|
||||
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;
|
||||
|
||||
-- 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_module` int(11),
|
||||
`id_plugin` int(11),
|
||||
`id_record` int(11) NOT NULL,
|
||||
`id_utente` int(11) NOT NULL,
|
||||
`id_utente_assegnato` int(11) NOT NULL,
|
||||
`checked_at` TIMESTAMP,
|
||||
`checked_at` TIMESTAMP NULL,
|
||||
`content` TEXT,
|
||||
`id_parent` int(11),
|
||||
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_utente`) 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;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `zz_checklist_templates` (
|
||||
CREATE TABLE IF NOT EXISTS `zz_checklists` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255),
|
||||
`id_module` 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,
|
||||
`id_parent` int(11),
|
||||
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,
|
||||
FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_templates`(`id`) ON DELETE CASCADE
|
||||
FOREIGN KEY (`id_checklist`) REFERENCES `zz_checklists`(`id`) ON DELETE CASCADE,
|
||||
FOREIGN KEY (`id_parent`) REFERENCES `zz_checklist_items`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
|
Loading…
Reference in New Issue