function getNumberOfPatches() { global $patch; #Max patches applied - start $patches = getNumberOfDonePatches(); $patch_count = count($patch); //Returns number of patches to be applied return $patch_count - $patches; }
$patch['111']['name'] = "Alter field name inv_it_gross_total to gross_total "; $patch['111']['patch'] = "ALTER TABLE `" . TB_PREFIX . "invoice_items` CHANGE `inv_it_gross_total` `gross_total` DOUBLE( 25, 2 ) NULL DEFAULT '0.00'"; $patch['111']['date'] = "20070523"; $patch['112']['name'] = "Alter field name inv_it_description to description "; $patch['112']['patch'] = "ALTER TABLE `" . TB_PREFIX . "invoice_items` CHANGE `inv_it_description` `description` TEXT NULL DEFAULT NULL"; $patch['112']['date'] = "20070523"; $patch['113']['name'] = "Alter field name inv_it_total to total"; $patch['113']['patch'] = "ALTER TABLE `" . TB_PREFIX . "invoice_items` CHANGE `inv_it_total` `total` DOUBLE( 25, 2 ) NULL DEFAULT '0.00'"; $patch['113']['date'] = "20070523"; $patch['114']['name'] = "Add logging table"; $patch['114']['patch'] = "CREATE TABLE `" . TB_PREFIX . "log` (\n`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n`userid` INT NOT NULL ,\n`sqlquerie` TEXT NOT NULL\n) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n"; $patch['114']['date'] = "20070523"; $patch['115']['name'] = "Add logging system preference"; $patch['115']['patch'] = "INSERT INTO `" . TB_PREFIX . "system_defaults` ( `id` , `name` , `value` ) VALUES (NULL , 'logging', '0');"; $patch['115']['date'] = "20070523"; $numpatchesdone = getNumberOfDonePatches(); $defaults = null; if ($numpatchesdone < 124) { // system defaults conversion patch // defaults query and DEFAULT NUMBER OF LINE ITEMS $sql_defaults = "SELECT * FROM " . TB_PREFIX . "defaults"; $sth = dbQuery($sql_defaults); $defaults = $sth->fetch(); } $patch['116']['name'] = "System defaults conversion patch - set default biller"; $patch['116']['patch'] = "UPDATE `" . TB_PREFIX . "system_defaults` SET value = {$defaults['def_biller']} where name = 'biller'"; $patch['116']['date'] = "20070523"; $patch['117']['name'] = "System defaults conversion patch - set default customer"; $patch['117']['patch'] = "UPDATE `" . TB_PREFIX . "system_defaults` SET value = {$defaults['def_customer']} where name = 'customer'"; $patch['117']['date'] = "20070523"; $patch['118']['name'] = "System defaults conversion patch - set default tax";
/** * Function invoice::max * * Used to get the max invoice id **/ public static function max() { global $auth_session; global $logger; $db=new db(); if ( getNumberOfDonePatches() < '179') { $sql ="SELECT max(id) as max FROM ".TB_PREFIX."invoices"; $sth = $db->query($sql); } else { $sql ="SELECT max(id) as max FROM ".TB_PREFIX."invoices WHERE domain_id = :domain_id"; $sth = $db->query($sql, ':domain_id', $auth_session->domain_id); } $count = $sth->fetch(); $logger->log('Max Invoice: '.$count['max'], Zend_Log::INFO); return $count['max']; }
/** * Function invoice::max * * Used to get the max invoice id * is called directly from sql_patches.php with invoice::max() * and hence $this->domain_id is not usable **/ public function max($domain_id = '') { global $logger; if (getNumberOfDonePatches() < '179') { $sql = "SELECT MAX(id) AS max FROM " . TB_PREFIX . "invoices"; $sth = dbQuery($sql); } else { if (!empty($domain_id)) { $this->domain_id = $domain_id; } $sql = "SELECT MAX(id) AS max FROM " . TB_PREFIX . "invoices WHERE domain_id = :domain_id"; $sth = dbQuery($sql, ':domain_id', $this->domain_id); } $count = $sth->fetch(); $logger->log('Max Invoice: ' . $count['max'], Zend_Log::INFO); return $count['max']; }