File manager - Edit - /home/wwwroot/camplus.hk/master.camplus.hk/public_html/application/modules/core/controllers/Update.php
Back
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Update extends MY_Controller { function __construct() { parent::__construct(); } function u1() { $check = $this->db->get_where('updates',array('ver'=>'1'))->row_array(); if(empty($check)) { $this->db->query("CREATE TABLE IF NOT EXISTS role_acl ( `id` int(11) NOT NULL auto_increment, `role_id` int(11) NOT NULL, `permission` TEXT NULL, PRIMARY KEY (`id`)) "); $this->db->select('roles.id,group_concat(permissions.permission_key) as permissions'); $this->db->from('permissions'); $this->db->join('roles_permission','permissions.id=roles_permission.permission_id'); $this->db->join('roles','roles.id=roles_permission.role_id'); $this->db->group_by('roles.id'); $results = $this->db->get()->result(); foreach($results as $result) { $this->db->insert('role_acl',array('role_id'=>$result->id,'permission'=>json_encode(explode(',',$result->permissions)))); } $this->db->query("CREATE TABLE IF NOT EXISTS updates ( `id` int(11) NOT NULL auto_increment, `remarks` text NOT NULL, `ver` VARCHAR(255) NOT NULL, `ack` TINYINT NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`)) "); $this->db->insert('updates',array('remarks'=>'Update modules and role permission updated','ver'=>'1','date'=>'2018-04-02')); $this->db->query("ALTER TABLE `ap_form_section_user` CHANGE `status` `status` ENUM('SUBMITTED','RELEASED') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;"); echo 'completed'; } else { echo 'already implemented'; } } function u2() { $check = $this->db->get_where('updates',array('ver'=>'2'))->row_array(); if(empty($check)) { $this->db->query("CREATE TABLE IF NOT EXISTS `ap_oa` ( `id` INT NOT NULL AUTO_INCREMENT , `ap_form` INT NOT NULL , `appraisee` INT NOT NULL , `oa` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;"); $this->db->query("ALTER TABLE `ap_form_section_unit_user` ADD `signature` LONGTEXT NOT NULL AFTER `type`;"); $this->db->insert('updates',array('remarks'=>'OA feature ready','ver'=>'2','date'=>'2018-05-07')); echo 'completed'; } else { echo 'already implemented'; } } function u3() { $check = $this->db->get_where('updates',array('ver'=>'3'))->row_array(); if(empty($check)) { $this->db->query("ALTER TABLE `ap_form_sections` ADD `weight` INT NOT NULL AFTER `form`;"); $this->db->insert('updates',array('remarks'=>'AP section ordering','ver'=>'3','date'=>'2018-05-11')); echo 'completed'; } else { echo 'already implemented'; } } function u4() { $check = $this->db->get_where('updates',array('ver'=>'4'))->row_array(); if(empty($check)) { $this->db->query("CREATE TABLE IF NOT EXISTS `ac_cmd` (`id` int(11) NOT NULL,`devID` int(11) NOT NULL,`receiver` int(11) NOT NULL,`ip` varchar(16) COLLATE utf8_unicode_ci NOT NULL,`cmd` int(11) NOT NULL,`ttl` int(11) NOT NULL,`time` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); $this->db->query("ALTER TABLE `ac_cmd` ADD UNIQUE KEY `id` (`id`);"); $this->db->query("ALTER TABLE `ac_cmd` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"); $this->db->insert('updates',array('remarks'=>'AC module cmd queue','ver'=>'4','date'=>'2018-05-23')); echo 'completed'; } else { echo 'already implemented'; } } function u5() { $check = $this->db->get_where('updates',array('ver'=>'5'))->row_array(); if(empty($check)) { $this->db->query("ALTER TABLE `ap_form_sections` ADD `sign` TINYINT NOT NULL DEFAULT '0' AFTER `form`"); $this->db->query("CREATE TABLE IF NOT EXISTS `ap_form_sign` ( `id` int(11) NOT NULL, `unit_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `counter` int(11) NOT NULL, `signature` longtext COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); $this->db->query("ALTER TABLE `ap_form_sign` ADD PRIMARY KEY (`id`);"); $this->db->query("ALTER TABLE `ap_form_sign` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;"); $this->db->insert('updates',array('remarks'=>'AP signature settings','ver'=>'5','date'=>'2018-06-11')); echo 'completed'; } else { echo 'already implemented'; } } function u6() { $check = $this->db->get_where('updates',array('ver'=>'6'))->row_array(); if(empty($check)) { $this->db->query("ALTER TABLE `notification` CHANGE `modules` `modules` ENUM('CORE','PR','AP','EB','TD','TB','AT','LS','OT','MIS','WF') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;"); $this->db->insert('updates',array('remarks'=>'Notification modules list update','ver'=>'6','date'=>'2018-12-13')); echo 'completed'; } else { echo 'already implemented'; } } function u7() { $this->db->select('*'); $ori = $this->db->from('users_cpd')->get()->row_array(); $check = $this->db->get_where('updates',array('ver'=>'7'))->row_array(); if (strpos($ori['dates'], '/') !== false && empty($check)) { $this->db->query("Update users_cpd SET dates = concat(SUBSTRING(dates,7,4),'-',SUBSTRING(dates,4,2),'-',SUBSTRING(dates,1,2)) WHERE dates LIKE '%/%'"); $this->db->insert('updates',array('remarks'=>'CPD changed to date object','ver'=>'7','date'=>'2018-12-13')); echo 'completed'; } else { echo 'already implemented'; } } function u8() { $check = $this->db->get_where('updates',array('ver'=>'8'))->row_array(); if(empty($check)) { $this->db->query("CREATE TABLE IF NOT EXISTS `assets` ( `id` int(10) NOT NULL, `asset_tag` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `model` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `status` enum('ARCHIVED','ACTIVE') DEFAULT NULL, `serial` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `asset_name` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `purchase_date` date DEFAULT NULL, `supplier_id` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `quantity` smallint(10) DEFAULT NULL, `purchase_cost` int(10) DEFAULT NULL, `warranty` tinyint(3) DEFAULT NULL, `venue_id` varchar(10) CHARACTER SET utf8 DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); $this->db->query("ALTER TABLE `assets` ADD PRIMARY KEY (`id`);"); $this->db->query("ALTER TABLE `assets` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;"); $this->db->query("ALTER TABLE `assets` ADD UNIQUE(`asset_tag`);"); $this->db->query("CREATE TABLE IF NOT EXISTS `licenses` ( `id` int(11) NOT NULL, `name` text COLLATE utf8_unicode_ci NOT NULL, `category_name` text COLLATE utf8_unicode_ci NOT NULL, `product_key` text COLLATE utf8_unicode_ci NOT NULL, `seats` int(11) NOT NULL, `company` text COLLATE utf8_unicode_ci NOT NULL, `manufacturer_id` int(11) NOT NULL, `licensed_to_name` text COLLATE utf8_unicode_ci NOT NULL, `licensed_to_email` text COLLATE utf8_unicode_ci NOT NULL, `reassignable` tinyint(4) NOT NULL, `supplier_id` int(11) NOT NULL, `order_number` text COLLATE utf8_unicode_ci NOT NULL, `purchase_cost` float NOT NULL, `purchase_date` date NOT NULL, `expiration_date` date NOT NULL, `termination_date` date NOT NULL, `purchase_order_number` text COLLATE utf8_unicode_ci NOT NULL, `depreciation` text COLLATE utf8_unicode_ci NOT NULL, `maintained` tinyint(4) NOT NULL, `notes` text COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); $this->db->query("ALTER TABLE `licenses` ADD PRIMARY KEY (`id`);"); $this->db->query("ALTER TABLE `licenses` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;"); $this->db->query("CREATE TABLE IF NOT EXISTS `manufacturers` ( `id` int(11) NOT NULL, `manufacturer` text COLLATE utf8_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); $this->db->query("ALTER TABLE `manufacturers` ADD PRIMARY KEY (`id`);"); $this->db->query("ALTER TABLE `manufacturers` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;"); $this->db->query("ALTER TABLE `manufacturers` CHANGE `manufacturer` `manufacturer` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;"); $this->db->query("ALTER TABLE `manufacturers` ADD UNIQUE(`manufacturer`);"); $this->db->query("CREATE TABLE IF NOT EXISTS `iv_record` ( `id` int(11) NOT NULL, `asset_id` int(11) NOT NULL, `uid` int(11) NOT NULL, `event` enum('CHECKOUT','AUDIT','CHANGE_VENUE') COLLATE utf8_unicode_ci NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `venue_id` int(11) NOT NULL, `quantity` int(11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); $this->db->query("ALTER TABLE `iv_record` ADD PRIMARY KEY (`id`);"); $this->db->query("ALTER TABLE `iv_record` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;"); $this->db->insert('updates',array('remarks'=>'Inventory Module table setup','ver'=>'8','date'=>'2018-12-31')); echo 'completed'; } else { echo 'already implemented'; } } function u9() { $check = $this->db->get_where('updates',array('ver'=>'9'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `student_score` ADD `ca` INT NOT NULL AFTER `subject_id`;"); echo 'completed'; } else { echo 'already implemented'; } } function u10() { $check = $this->db->get_where('updates',array('ver'=>'10'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `purchase_request` ADD `is_asset` INT NULL AFTER `delivery_date`;"); echo 'completed'; } else { echo 'already implemented'; } } function u11() { $check = $this->db->get_where('updates',array('ver'=>'11'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `pr_budget_items` ADD `workgroup` varchar(255) CHARACTER SET utf8 DEFAULT '' AFTER `status`;"); echo 'completed'; } else { echo 'already implemented'; } } function u12() { $check = $this->db->get_where('updates',array('ver'=>'12'))->row_array(); if (empty($check)) { $this->db->query("CREATE TABLE IF NOT EXISTS `email_queue` ( `id` int(11) NOT NULL AUTO_INCREMENT, `to` varchar(255) NOT NULL, `cc` varchar(255) DEFAULT NULL, `bcc` varchar(255) DEFAULT NULL, `message` text NOT NULL, `status` enum('pending','sending','sent','failed') DEFAULT NULL, `date` datetime DEFAULT NULL, `headers` text, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8"); echo 'completed'; } else { echo 'already implemented'; } } function u13() { $check = $this->db->get_where('updates',array('ver'=>'13'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `ap_form_sections` ADD `hideoa` INT NULL AFTER `form`;"); echo 'completed'; } else { echo 'already implemented'; } } function u14() { $check = $this->db->get_where('updates',array('ver'=>'14'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `ls_approval_record` ADD `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `createddate`;"); $this->db->query("update `ls_approval_record` set updated_at=createddate;"); echo 'completed'; } else { echo 'already implemented'; } } function u15() { $check = $this->db->get_where('updates',array('ver'=>'15'))->row_array(); if (empty($check)) { $this->db->query("ALTER TABLE `ap_form_sections` ADD `viewable_to_user` INT NULL DEFAULT '0' AFTER `weight`, ADD `is_counter_sign` INT NULL DEFAULT '0' AFTER `viewable_to_user`;"); echo 'completed'; } else { echo 'already implemented'; } } }
| ver. 1.4 |
Github
|
.
| PHP 7.2.34 | Generation time: 0.4 |
proxy
|
phpinfo
|
Settings