You should have received a copy of the GNU General Public License along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- @package order @author the order plugin team @copyright Copyright (c) 2010-2015 Order plugin team @license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/order @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; $bill = new PluginOrderBill(); if (isset($_REQUEST['add'])) { $bill->add($_REQUEST); Html::back(); } if (isset($_REQUEST['update'])) { $bill->update($_REQUEST); Html::back(); } if (isset($_REQUEST['purge'])) { $bill->delete($_REQUEST); $bill->redirectToList(); } if (isset($_POST['action'])) { // Retrieve configuration for generate assets feature $order_item = new PluginOrderOrder_Item(); switch ($_POST['chooseAction']) { case 'bill':
public static function install(Migration $migration) { global $DB; $table = getTableForItemType(__CLASS__); if (!TableExists($table)) { $migration->displayMessage("Installing {$table}"); $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_order_bills` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `number` varchar(255) COLLATE utf8_unicode_ci DEFAULT '',\n `billdate` datetime DEFAULT NULL,\n `validationdate` datetime DEFAULT NULL,\n `comment` text COLLATE utf8_unicode_ci,\n `plugin_order_billstates_id` int(11) NOT NULL DEFAULT '0',\n `value` decimal(20,4) NOT NULL DEFAULT '0.0000',\n `plugin_order_billtypes_id` int(11) NOT NULL DEFAULT '0',\n `suppliers_id` int(11) NOT NULL DEFAULT '0',\n `plugin_order_orders_id` int(11) NOT NULL DEFAULT '0',\n `users_id_validation` int(11) NOT NULL DEFAULT '0',\n `entities_id` int(11) NOT NULL DEFAULT '0',\n `is_recursive` int(11) NOT NULL DEFAULT '0',\n `notepad` text COLLATE utf8_unicode_ci,\n PRIMARY KEY (`id`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;"; $DB->query($query) or die($DB->error()); } else { if (FieldExists("glpi_plugin_order_orders_suppliers", "num_bill")) { //Migrate bills $bill = new PluginOrderBill(); $query = "SELECT * FROM `glpi_plugin_order_orders_suppliers`"; foreach (getAllDatasFromTable('glpi_plugin_order_orders_suppliers') as $data) { if (!is_null($data['num_bill']) && $data['num_bill'] != '' && !countElementsInTable('glpi_plugin_order_bills', "`number`='" . $data['num_bill'] . "'")) { //create new bill and link it to the order $tmp['name'] = $tmp['number'] = $data['num_bill']; //Get supplier from the order $tmp['suppliers_id'] = $data['suppliers_id']; //Bill has the same entities_id and is_recrusive $tmp['entities_id'] = $data['entities_id']; $tmp['is_recursive'] = $data['is_recursive']; //Link bill to order $tmp['plugin_order_orders_id'] = $data['plugin_order_orders_id']; //Create bill $bills_id = $bill->add($tmp); //All order items are now linked to this bill $query = "UPDATE `glpi_plugin_order_orders_items`\n SET `plugin_order_bills_id` = '{$bills_id}'\n WHERE `plugin_order_orders_id` = '" . $data['plugin_order_orders_id'] . "'"; $DB->query($query); } } } $migration->changeField($table, "value", "value", "decimal(20,4) NOT NULL DEFAULT '0.0000'"); $migration->migrationOneTable($table); } $migration->dropField("glpi_plugin_order_orders_suppliers", "num_bill"); $migration->migrationOneTable("glpi_plugin_order_orders_suppliers"); }