diff --git a/equipment.php b/equipment.php index db04997..c9c40f1 100644 --- a/equipment.php +++ b/equipment.php @@ -22,55 +22,35 @@ -define('EQUIPMENT_PLUGIN_VERSION', - '0.2'); - -define('EQUIPMENT_TABLE', - TABLE_PREFIX . 'equipment'); -define('EQUIPMENT_CATEGORY_TABLE', - TABLE_PREFIX . 'equipment_category'); -define('EQUIPMENT_STATUS_TABLE', - TABLE_PREFIX . 'equipment_status'); -define('EQUIPMENT_TICKET_TABLE', - TABLE_PREFIX . 'equipment_ticket'); +define('EQUIPMENT_PLUGIN_VERSION', '0.2'); + +define('EQUIPMENT_TABLE', TABLE_PREFIX . 'equipment'); +define('EQUIPMENT_CATEGORY_TABLE', TABLE_PREFIX . 'equipment_category'); +define('EQUIPMENT_STATUS_TABLE', TABLE_PREFIX . 'equipment_status'); +define('EQUIPMENT_TICKET_TABLE', TABLE_PREFIX . 'equipment_ticket'); define('EQUIPMENT_TICKET_RECURRING__TABLE', TABLE_PREFIX . 'equipment_ticket_recurring'); -define('EQUIPMENT_TICKET_VIEW', - TABLE_PREFIX . 'EquipmentTicketView'); - -define('OST_WEB_ROOT', - osTicket::get_root_path(__DIR__)); - -define('EQUIPMENT_WEB_ROOT', - OST_WEB_ROOT . 'scp/dispatcher.php/equipment/'); - -define('OST_ROOT', - INCLUDE_DIR . '../'); - -define('PLUGINS_ROOT', - INCLUDE_DIR . 'plugins/'); - -define('EQUIPMENT_PLUGIN_ROOT', - __DIR__ . '/'); -define('EQUIPMENT_INCLUDE_DIR', - EQUIPMENT_PLUGIN_ROOT . 'include/'); -define('EQUIPMENT_MODEL_DIR', - EQUIPMENT_INCLUDE_DIR . 'model/'); -define('EQUIPMENT_CONTROLLER_DIR', - EQUIPMENT_INCLUDE_DIR . 'controller/'); - -define('EQUIPMENT_APP_DIR', - EQUIPMENT_PLUGIN_ROOT . 'app/'); -define('EQUIPMENT_ASSETS_DIR', - EQUIPMENT_PLUGIN_ROOT . 'assets/'); -define('EQUIPMENT_VENDOR_DIR', - EQUIPMENT_PLUGIN_ROOT . 'vendor/'); -define('EQUIPMENT_VIEWS_DIR', - EQUIPMENT_PLUGIN_ROOT . 'views/'); -define('EQUIPMENT_STAFFINC_DIR', - EQUIPMENT_INCLUDE_DIR . 'staff/'); -define('EQUIPMENT_CLIENTINC_DIR', - EQUIPMENT_INCLUDE_DIR . 'client/'); +define('EQUIPMENT_TICKET_VIEW', TABLE_PREFIX . 'EquipmentTicketView'); + +define('OST_WEB_ROOT', osTicket::get_root_path(__DIR__)); + +define('EQUIPMENT_WEB_ROOT', OST_WEB_ROOT . 'scp/dispatcher.php/equipment/'); + +define('OST_ROOT', INCLUDE_DIR . '../'); + +define('PLUGINS_ROOT', INCLUDE_DIR . 'plugins/'); + +define('EQUIPMENT_PLUGIN_ROOT', __DIR__ . '/'); +define('EQUIPMENT_INCLUDE_DIR', EQUIPMENT_PLUGIN_ROOT . 'include/'); +define('EQUIPMENT_MODEL_DIR', EQUIPMENT_INCLUDE_DIR . 'model/'); +define('EQUIPMENT_CONTROLLER_DIR', EQUIPMENT_INCLUDE_DIR . 'controller/'); + +define('EQUIPMENT_APP_DIR', EQUIPMENT_PLUGIN_ROOT . 'app/'); +define('EQUIPMENT_ASSETS_DIR', EQUIPMENT_PLUGIN_ROOT . 'assets/'); +define('EQUIPMENT_VENDOR_DIR', EQUIPMENT_PLUGIN_ROOT . 'vendor/'); +define('EQUIPMENT_VIEWS_DIR', EQUIPMENT_PLUGIN_ROOT . 'views/'); +define('EQUIPMENT_STAFFINC_DIR', EQUIPMENT_INCLUDE_DIR . 'staff/'); +define('EQUIPMENT_CLIENTINC_DIR', EQUIPMENT_INCLUDE_DIR . 'client/'); require_once (EQUIPMENT_VENDOR_DIR . 'autoload.php'); spl_autoload_register(array('EquipmentPlugin', 'autoload')); @@ -80,24 +60,15 @@ class EquipmentPlugin extends Plugin { var $config_class = 'EquipmentConfig'; public static function autoload($className) { - $className = ltrim($className, - '\\'); + $className = ltrim($className, '\\'); $fileName = ''; $namespace = ''; - if ($lastNsPos = strrpos($className, - '\\')) { - $namespace = substr($className, - 0, - $lastNsPos); - $className = substr($className, - $lastNsPos + 1); - $fileName = str_replace('\\', - DIRECTORY_SEPARATOR, - $namespace) . DIRECTORY_SEPARATOR; + if ($lastNsPos = strrpos($className, '\\')) { + $namespace = substr($className, 0, $lastNsPos); + $className = substr($className, $lastNsPos + 1); + $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } - $fileName .= str_replace('_', - DIRECTORY_SEPARATOR, - $className) . '.php'; + $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $fileName = 'include/' . $fileName; if (file_exists(EQUIPMENT_PLUGIN_ROOT . $fileName)) { @@ -118,16 +89,18 @@ function bootstrap() { if ($config->get('equipment_backend_enable')) { $this->createStaffMenu(); - - if ($config->get('equipment_frontend_enable')) { - $this->createFrontMenu(); - } } - Signal::connect('apps.scp', - array('EquipmentPlugin', 'callbackDispatch')); - + if ($config->get('equipment_frontend_enable')) { + $this->createFrontMenu(); + } + + Signal::connect('apps.scp', array('EquipmentPlugin', 'callbackDispatch')); + Signal::connect('cron', array('\controller\TicketRecurring', 'runRecurrance')); + + //call it anyway, not sure if cron works like it is suppose to. + \controller\TicketRecurring::runRecurrance(); } public static function getCustomForm() { @@ -146,118 +119,84 @@ static public function callbackDispatch($object, $data) { $categories_url = url('^/equipment.*categories/', patterns( 'controller\EquipmentCategory', - url_get('^list$', - 'listAction'), - url_get('^listJson$', - 'listJsonAction'), - url_get('^view/(?P\d+)$', - 'viewAction'), + url_get('^list$', 'listAction'), + url_get('^listJson$', 'listJsonAction'), + url_get('^view/(?P\d+)$', 'viewAction'), url_get('^openTicketsJson/(?P\d+)$', 'openTicketsJsonAction'), url_get('^closedTicketsJson/(?P\d+)$', 'closedTicketsJsonAction'), url_get('^getItemsJson/(?P\d+)$', 'categoryItemsJsonAction'), - url_post('^save', - 'saveAction'), - url_post('^delete', - 'deleteAction') + url_post('^save', 'saveAction'), + url_post('^delete', 'deleteAction') )); $item_url = url('^/equipment.*item/', patterns( 'controller\EquipmentItem', - url_get('^list$', - 'listAction'), - url_get('^listJson$', - 'listJsonAction'), - url_get('^view/(?P\d+)$', - 'viewAction'), - url_get('^new/(?P\d+)$', - 'newAction'), - url_post('^publish', - 'publishAction'), - url_post('^activate', - 'activateAction'), - url_post('^save', - 'saveAction'), + url_get('^list$', 'listAction'), + url_get('^listJson$', 'listJsonAction'), + url_get('^view/(?P\d+)$', 'viewAction'), + url_get('^new/(?P\d+)$', 'newAction'), + url_post('^publish', 'publishAction'), + url_post('^activate', 'activateAction'), + url_post('^save', 'saveAction'), url_get('^openTicketsJson/(?P\d+)$', 'openTicketsJsonAction'), url_get('^closedTicketsJson/(?P\d+)$', 'closedTicketsJsonAction'), - url_get('^getDynamicForm/(?P\d+)$', - 'getDynamicForm'), - url_post('^delete', - 'deleteAction') + url_get('^getDynamicForm/(?P\d+)$', 'getDynamicForm'), + url_post('^delete', 'deleteAction') )); $status_url = url('^/equipment.*status/', patterns( 'controller\EquipmentStatus', - url_get('^list$', - 'listAction'), - url_get('^view/(?P\d+)$', - 'viewAction'), - url_get('^new/(?P\d+)$', - 'newAction'), - url_get('^listJson$', - 'listJsonAction'), + url_get('^list$', 'listAction'), + url_get('^view/(?P\d+)$', 'viewAction'), + url_get('^new/(?P\d+)$', 'newAction'), + url_get('^listJson$', 'listJsonAction'), url_get('^getItemsJson/(?P\d+)$', 'statusItemsJsonAction'), - url_post('^save', - 'saveAction'), - url_post('^delete', - 'deleteAction') + url_post('^save', 'saveAction'), + url_post('^delete', 'deleteAction') )); $recurring_url = url('^/equipment.*recurring/', patterns( 'controller\TicketRecurring', - url_get('^list$', - 'listAction'), - url_get('^view/(?P\d+)$', - 'viewAction'), + url_get('^list$', 'listAction'), + url_get('^view/(?P\d+)$', 'viewAction'), url_get('^viewByTicket/(?P\d+)$', 'viewByTicketAction'), - url_get('^addByTicket/(?P\d+)$', - 'addByTicketAction'), - url_get('^new/(?P\d+)$', - 'newAction'), - url_get('^listJson$', - 'listJsonAction'), + url_get('^addByTicket/(?P\d+)$', 'addByTicketAction'), + url_get('^new/(?P\d+)$', 'newAction'), + url_get('^listJson$', 'listJsonAction'), url_get('^getItemsJson/(?P\d+)$', 'statusItemsJsonAction'), - url_get('^listTicketsJson$', - 'listTicketsJson'), - url_get('^listEquipmentJson$', - 'listEquipmentJson'), - url_post('^save', - 'saveAction'), - url_post('^delete', - 'deleteAction'), - url_get('^test', - 'test') + url_get('^listTicketsJson$', 'listTicketsJson'), + url_get('^listEquipmentJson$', 'listEquipmentJson'), + url_post('^save', 'saveAction'), + url_post('^delete', 'deleteAction'), + url_get('^test', 'test') )); $media_url = url('^/equipment.*assets/', patterns( 'controller\MediaController', - url_get('^(?P.*)$', - 'defaultAction'))) + url_get('^(?P.*)$', 'defaultAction'))) ; $dashboard_url = url('^/equipment.*dashboard/', patterns( - 'controller\Dashboard', - url_get('.*', - 'viewAction'))) + 'controller\Dashboard', url_get('.*', 'viewAction'))) ; $redirect_url = url('^/equipment.*ostroot/', patterns( 'controller\MediaController', - url_get('^(?P.*)$', - 'redirectAction'))) + url_get('^(?P.*)$', 'redirectAction'))) ; $object->append($media_url); @@ -285,8 +224,7 @@ function createStaffMenu() { */ function createFrontMenu() { Application::registerClientApp('Equipment Status', - 'equipment_front/index.php', - array(iconclass => 'equipment')); + 'equipment_front/index.php', array(iconclass => 'equipment')); } /** diff --git a/equipment_front/equipment.inc.php b/equipment_front/equipment.inc.php index 903eb88..884a070 100644 --- a/equipment_front/equipment.inc.php +++ b/equipment_front/equipment.inc.php @@ -13,9 +13,9 @@ **********************************************************************/ define('ROOT_PATH','../'); require_once('../client.inc.php'); -require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php'); +//require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php'); /* Bail out if knowledgebase is disabled or if we have no public-published Equipment. */ -if(!Equipment::countPublishedEquipment()) { +if(!\model\Equipment::countPublishedEquipment()) { header('Location: ../'); exit; } diff --git a/equipment_front/equipment.php b/equipment_front/equipment.php index d0875da..35ee294 100644 --- a/equipment_front/equipment.php +++ b/equipment_front/equipment.php @@ -12,22 +12,21 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ require('equipment.inc.php'); -require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment.php'); $equipment=$category=$status=null; -if($_REQUEST['id'] && !($equipment=Equipment::lookup($_REQUEST['id']))) +if($_REQUEST['id'] && !($equipment=new \model\Equipment($_REQUEST['id']))) $errors['err']='Unknown or invalid equpment'; -if(!$equipment && $_REQUEST['cid'] && !($category=Equipment_Category::lookup($_REQUEST['cid']))) +if(!$equipment && $_REQUEST['cid'] && !($category=new \model\EquipmentCategory($_REQUEST['cid']))) $errors['err']='Unknown or invalid equipment category'; -if(!$equipment && $_REQUEST['status'] && !($status=Equipment_Status::lookup($_REQUEST['status']))) +if(!$equipment && $_REQUEST['status'] && !($status=new \model\EquipmentStatus($_REQUEST['status']))) $errors['err']='Unknown or invalid equipment status'; $inc='equipment_list.inc.php'; //FAQs landing page. -if($equipment && $equipment->isPublished()) { +if($equipment && $equipment->getIspublished()) { $inc='equipment.inc.php'; -} elseif($category && $category->isPublic() && $_REQUEST['a']!='search') { +} elseif($category && $category->getIspublic() && $_REQUEST['a']!='search') { $inc='equipment-category.inc.php'; } elseif ($status && $_REQUEST['a']!='search') { $inc='equipment-status.inc.php'; diff --git a/equipment_front/images/green_dot.png b/equipment_front/images/green_dot.png new file mode 100644 index 0000000..25325bd Binary files /dev/null and b/equipment_front/images/green_dot.png differ diff --git a/equipment_front/images/header-bg.png b/equipment_front/images/header-bg.png new file mode 100644 index 0000000..dc3e1d5 Binary files /dev/null and b/equipment_front/images/header-bg.png differ diff --git a/equipment_front/images/new_category.png b/equipment_front/images/new_category.png new file mode 100644 index 0000000..ef036c2 Binary files /dev/null and b/equipment_front/images/new_category.png differ diff --git a/equipment_front/images/ost-logo.png b/equipment_front/images/ost-logo.png new file mode 100644 index 0000000..0cf40c7 Binary files /dev/null and b/equipment_front/images/ost-logo.png differ diff --git a/equipment_front/images/red_dot.png b/equipment_front/images/red_dot.png new file mode 100644 index 0000000..59e9fb1 Binary files /dev/null and b/equipment_front/images/red_dot.png differ diff --git a/equipment_front/images/yellow_dot.png b/equipment_front/images/yellow_dot.png new file mode 100644 index 0000000..b1b4e34 Binary files /dev/null and b/equipment_front/images/yellow_dot.png differ diff --git a/equipment_front/index.php b/equipment_front/index.php index 5d59256..c464a17 100644 --- a/equipment_front/index.php +++ b/equipment_front/index.php @@ -14,7 +14,6 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ require('equipment.inc.php'); -require_once(EQUIPMENT_INCLUDE_DIR.'class.equipment_category.php'); $inc='equipment_list.inc.php'; require(CLIENTINC_DIR.'header.inc.php'); require(EQUIPMENT_CLIENTINC_DIR.$inc); diff --git a/include/client/equipment-category.inc.php b/include/client/equipment-category.inc.php index 8eb5aa5..ccb1115 100644 --- a/include/client/equipment-category.inc.php +++ b/include/client/equipment-category.inc.php @@ -13,15 +13,15 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -if(!defined('OSTCLIENTINC') || !$category || !$category->isPublic()) die('Access Denied'); +if(!defined('OSTCLIENTINC') || !$category || !$category->getIspublic()) die('Access Denied'); ?>

getName() ?>

-getDescription()); ?> +getDescription()); ?>


%s %s  %s', - '', + '', $row['equipment_id'], - Format::htmlchars($row['Equipment']), $row['Status']); + \Format::htmlchars($row['Equipment']), $row['Status']); } echo ' diff --git a/include/client/equipment-status.inc.php b/include/client/equipment-status.inc.php index 0d22595..4d83317 100644 --- a/include/client/equipment-status.inc.php +++ b/include/client/equipment-status.inc.php @@ -17,11 +17,11 @@ ?>

getName() ?>

-getDescription()); ?> +getDescription()); ?>


%s  %s', $row['equipment_id'], 'style="color:'.$row['color'].'"', - Format::htmlchars($row['Equipment']), $row['Status']); + \Format::htmlchars($row['Equipment']), $row['Status']); } echo ' diff --git a/include/client/equipment.inc.php b/include/client/equipment.inc.php index e2afcf7..792b11e 100644 --- a/include/client/equipment.inc.php +++ b/include/client/equipment.inc.php @@ -14,7 +14,7 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -if(!defined('OSTCLIENTINC') || !$equipment || !$equipment->isPublished()) die('Access Denied'); +if(!defined('OSTCLIENTINC') || !$equipment || !$equipment->getIspublished()) die('Access Denied'); $category=$equipment->getCategory(); @@ -25,14 +25,14 @@ » getName(); ?>
-getName() ?> +getAsset_id() ?>

-getImage();?>" width="20" height="20"/> +getStatus()->getImage();?>" width="20" height="20"/> getStatus()); ?>


-
 Last updated getUpdateDate()); ?>
+
 Last updated getUpdated()); ?>
diff --git a/include/client/equipment_list.inc.php b/include/client/equipment_list.inc.php deleted file mode 100644 index b7bffec..0000000 --- a/include/client/equipment_list.inc.php +++ /dev/null @@ -1,161 +0,0 @@ - - Copyright (c) 2013 XpressTek - http://www.xpresstek.net - - Released under the GNU General Public License WITHOUT ANY WARRANTY. - See LICENSE.TXT for details. - - vim: expandtab sw=4 ts=4 sts=4: -**********************************************************************/ -if(!defined('OSTCLIENTINC')) die('Access Denied'); - -?> -

Equipment Status

- -
-
-Search Results
"; - if(($res=db_query($sql)) && ($num=db_num_rows($res))) { - echo '
'.$num.' Equipment matched your search criteria. -
    '; - while($row=db_fetch_array($res)) { - echo sprintf(' -
  1. %s
  2. ', - $row['equipment_id'],$row['name'],$row['ispublished']?'Published':'Internal'); - } - echo '
-
'; - } else { - echo 'The search did not match any items.'; - } -} else { //Category Listing. - $sql='SELECT cat.category_id, cat.name, cat.description, cat.ispublic, count(equipment.equipment_id) as equipments ' - .' FROM '.EQUIPMENT_CATEGORY_TABLE.' cat ' - .' LEFT JOIN '.EQUIPMENT_TABLE.' equipment ON(equipment.category_id=cat.category_id AND equipment.ispublished=1) ' - .' WHERE cat.ispublic=1 ' - .' GROUP BY cat.category_id ' - .' HAVING equipments>0 ' - .' ORDER BY cat.name'; - if(($res=db_query($sql)) && db_num_rows($res)) { - echo '
Click on the category to browse equipment.
-
    '; - while($row=db_fetch_array($res)) { - - echo sprintf(' -
  • - -

    %s (%d)

    - %s -
  • ',$row['category_id'], - Format::htmlchars($row['name']),$row['equipments'], - Format::safe_html($row['description'])); - } - echo '
'; - - $sql='SELECT status.status_id, status.name, status.color as color, count(equipment.equipment_id) as equipments ' - .' FROM '.EQUIPMENT_STATUS_TABLE.' status ' - .' LEFT JOIN '.EQUIPMENT_TABLE.' equipment ON(equipment.status_id=status.status_id AND equipment.ispublished=1) ' - .' GROUP BY status.status_id' - .' HAVING equipments>0 ' - .' ORDER BY status.name'; - if(($res=db_query($sql)) && db_num_rows($res)) { - echo '
Click on the status to browse equipment.
-
    '; - while($row=db_fetch_array($res)) { - - echo sprintf(' -
  • - -

    %s (%d)

    - -
  • ', - - $row['status_id'], - 'style="color:'.$row['color'].'"', - Format::htmlchars($row['name']),$row['equipments']); - - } - echo '
'; - } - } - else { - echo 'NO items found'; - } -} -?> - diff --git a/include/client/open.inc.php b/include/client/open.inc.php deleted file mode 100644 index e3e3446..0000000 --- a/include/client/open.inc.php +++ /dev/null @@ -1,127 +0,0 @@ -isValid()) { - $info=array('name'=>$thisclient->getName(), - 'email'=>$thisclient->getEmail(), - 'phone'=>$thisclient->getPhone()); -} - -$info=($_POST && $errors)?Format::htmlchars($_POST):$info; -?> -

Open a New Ticket

-

Please fill in the form below to open a new ticket.

-
- - - - - - - - -getForm($_POST); - if ($_POST) $uform->isValid(); - $uform->render(false, 'Your Information'); - } - else { ?> - - - - - - isEquipmentEnabledFrontEnd()) { ?> - - - - - - - - - - - getForm($_POST); - if ($_POST) $tform->isValid(); - $tform->render(false); ?> - - - isCaptchaEnabled() && (!$thisclient || !$thisclient->isValid())) { - if($_POST && $errors && !$errors['captcha']) - $errors['captcha']='Please re-enter the text again'; - ?> - - - - - - - -
Help Topic: - - -

Email:getEmail(); ?>
Client:getName(); ?>
Equipment Affected: - - - -
CAPTCHA Text: - -    - - Enter the text shown on the image. - -
 
-
-

- - - -

-
- diff --git a/install/sql/install_equipment.sql b/install/sql/install_equipment.sql index a1caf57..fa069bb 100644 --- a/install/sql/install_equipment.sql +++ b/install/sql/install_equipment.sql @@ -325,4 +325,11 @@ BEGIN END$ -UPDATE `%TABLE_PREFIX%plugin` SET version='0.2' WHERE name = 'Equipment Manager'$ \ No newline at end of file +DROP PROCEDURE IF EXISTS `%TABLE_PREFIX%update_version`$ +CREATE PROCEDURE `%TABLE_PREFIX%update_version`(plugin_name VARCHAR(250), plugin_version VARCHAR(100)) +begin + SET @id = (SELECT id FROM `%TABLE_PREFIX%plugin` WHERE `name`= plugin_name); + UPDATE `%TABLE_PREFIX%plugin` SET version = plugin_version WHERE id=@id; +END$ + +call `%TABLE_PREFIX%update_version`('Equipment Manager', '0.2')$ \ No newline at end of file diff --git a/install/sql/remove_equipment.sql b/install/sql/remove_equipment.sql index e469751..3700a01 100644 --- a/install/sql/remove_equipment.sql +++ b/install/sql/remove_equipment.sql @@ -1,4 +1,5 @@ DROP TRIGGER IF EXISTS `%TABLE_PREFIX%ticket_event_AINS`$ +DROP TRIGGER IF EXISTS `%TABLE_PREFIX%ticket_event_AUPD`$ DROP VIEW IF EXISTS `%TABLE_PREFIX%EquipmentFormView`$ DROP VIEW IF EXISTS `%TABLE_PREFIX%EquipmentTicketView`$ DROP TRIGGER IF EXISTS `%TABLE_PREFIX%equipment_status_ADEL`$ @@ -35,6 +36,7 @@ END$ CALL `%TABLE_PREFIX%RemoveEquipmentFormFields`$ DROP PROCEDURE IF EXISTS `%TABLE_PREFIX%RemoveEquipmentFormFields`$ +DROP PROCEDURE IF EXISTS `%TABLE_PREFIX%update_version`$ diff --git a/install/sql/upgrade_equipment.sql b/install/sql/upgrade_equipment.sql index 91562ed..212d0fb 100644 --- a/install/sql/upgrade_equipment.sql +++ b/install/sql/upgrade_equipment.sql @@ -153,6 +153,34 @@ BEGIN END IF; END$ +DROP TRIGGER IF EXISTS `%TABLE_PREFIX%equipment_status_AINS`$ + +CREATE TRIGGER `%TABLE_PREFIX%equipment_status_AINS` AFTER INSERT ON `%TABLE_PREFIX%equipment_status` FOR EACH ROW +BEGIN + SET @pk=NEW.status_id; + SET @list_pk=(SELECT id FROM `%TABLE_PREFIX%list` WHERE name='equipment_status'); + INSERT INTO `%TABLE_PREFIX%list_items` (list_id, `value`, `properties`) + VALUES (@list_pk, NEW.name, CONCAT('',@pk)); +END$ + +DROP TRIGGER IF EXISTS `%TABLE_PREFIX%equipment_status_AUPD`$ + +CREATE TRIGGER `%TABLE_PREFIX%equipment_status_AUPD` AFTER UPDATE ON `%TABLE_PREFIX%equipment_status` FOR EACH ROW +BEGIN + SET @pk=NEW.status_id; + SET @list_pk=(SELECT id FROM `%TABLE_PREFIX%list` WHERE name='equipment_status'); + UPDATE `%TABLE_PREFIX%list_items` SET `value`= NEW.name WHERE `properties`= CONCAT('',@pk) AND list_id=@list_pk; +END$ + +DROP TRIGGER IF EXISTS `%TABLE_PREFIX%equipment_status_ADEL`$ + +CREATE TRIGGER `%TABLE_PREFIX%equipment_status_ADEL` AFTER DELETE ON `%TABLE_PREFIX%equipment_status` FOR EACH ROW +BEGIN + SET @pk=OLD.status_id; + SET @list_pk=(SELECT id FROM `%TABLE_PREFIX%list` WHERE name='equipment_status'); + DELETE FROM `%TABLE_PREFIX%list_items` WHERE list_id = @list_pk AND properties=CONCAT('',@pk); +END$ + DROP VIEW IF EXISTS `%TABLE_PREFIX%EquipmentFormView`$ CREATE VIEW `%TABLE_PREFIX%EquipmentFormView` AS @@ -264,7 +292,14 @@ BEGIN UPDATE `%TABLE_PREFIX%equipment` SET status_id = @status_id WHERE equipment_id=@equipment_id; END IF; - END IF; + +END$ + +DROP PROCEDURE IF EXISTS `%TABLE_PREFIX%update_version`$ +CREATE PROCEDURE `%TABLE_PREFIX%update_version`(plugin_name VARCHAR(250), plugin_version VARCHAR(100)) +begin + SET @id = (SELECT id FROM `%TABLE_PREFIX%plugin` WHERE `name`= plugin_name); + UPDATE `%TABLE_PREFIX%plugin` SET version = plugin_version WHERE id=@id; END$ -UPDATE `%TABLE_PREFIX%plugin` SET version='0.2' WHERE name = 'Equipment Manager'$ \ No newline at end of file +call `%TABLE_PREFIX%update_version`('Equipment Manager', '0.2')$ \ No newline at end of file