From 1a8a31eabf54ebe1d671b9119934d947e31dfea8 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 14:26:22 +0100 Subject: [PATCH 01/11] setData function converted to static to fix some errors. --- library/Shineisp/Commons/Layout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Shineisp/Commons/Layout.php b/library/Shineisp/Commons/Layout.php index 85bdd98a..d500812e 100644 --- a/library/Shineisp/Commons/Layout.php +++ b/library/Shineisp/Commons/Layout.php @@ -66,7 +66,7 @@ public static function getData($module, $skin) { * @param string $controller * @param string $skin [base] */ - private function setData($xmlobject, $module, $controller, $skin = "base") { + private static function setData($xmlobject, $module, $controller, $skin = "base") { // Get the default project resources if (count ( $xmlobject )) { From 61a488285fce1c1b0a89bae3cbd89e7291f73c6e Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 14:31:02 +0100 Subject: [PATCH 02/11] Some functions made static --- library/Shineisp/Commons/Utilities.php | 58 +++++++++++++------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/library/Shineisp/Commons/Utilities.php b/library/Shineisp/Commons/Utilities.php index 22a36601..1070d80a 100644 --- a/library/Shineisp/Commons/Utilities.php +++ b/library/Shineisp/Commons/Utilities.php @@ -28,7 +28,7 @@ public static function getQuarterByMonth($monthNumber) { * @param string $database * @return boolean or string */ - static public function chkdatabase($username,$password,$hostname,$database){ + public static function chkdatabase($username,$password,$hostname,$database){ try{ $dsn = "mysql://$username:$password@$hostname/$database"; $conn = Doctrine_Manager::connection($dsn, 'shineisp test connection'); @@ -54,7 +54,7 @@ static public function chkdatabase($username,$password,$hostname,$database){ * @param string $filename * @param string $destination */ - static public function unZip($filename, $destination){ + public static function unZip($filename, $destination){ $zip = new ZipArchive; $res = $zip->open($filename); if ($res === TRUE) { @@ -121,7 +121,7 @@ public static function log($message, $filename = "errors.log") { * Check if the browser is an Apple client * @return boolean */ - static public function isAppleClient(){ + public static function isAppleClient(){ if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad')) { return true; } @@ -132,7 +132,7 @@ static public function isAppleClient(){ * Get the google latitude longitude * @param string $address */ - static public function getCoordinates($address){ + public static function getCoordinates($address){ $address = urlencode($address); $uri = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=true"; $json = @file_get_contents ( $uri ); @@ -150,7 +150,7 @@ static public function getCoordinates($address){ * Check if the domain is valid * @param unknown_type $domain_name */ - static public function is_valid_domain_name($url) { + public static function is_valid_domain_name($url) { if (preg_match ( "/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i", $url )) { return true; } else { @@ -162,7 +162,7 @@ static public function is_valid_domain_name($url) { * Create a little table using a multidimensional array * @param array $data */ - static public function array2table(array $data){ + public static function array2table(array $data){ $cell_address = "[A1,A2,D3,H3]"; $ar_columns = array_keys($data[0]); @@ -199,7 +199,7 @@ static public function array2table(array $data){ * @param string $directory * */ - static public function dirlist($dir) { + public static function dirlist($dir) { $dirs = array (); $next = 0; @@ -222,7 +222,7 @@ static public function dirlist($dir) { * This function simply returns an array containing a list of a directory's contents. * @param unknown_type $directory */ - static public function getDirectoryList ($directory) + public static function getDirectoryList ($directory) { // create an array to hold directory list @@ -254,7 +254,7 @@ static public function getDirectoryList ($directory) * Check if the string is a date * @param unknown_type $str */ - static public function isDate($str) { + public static function isDate($str) { if (! empty ( $str )) { $str = str_replace ( "/", "-", $str ); $stamp = strtotime ( $str ); @@ -274,7 +274,7 @@ static public function isDate($str) { return FALSE; } - static public function isAjax() { + public static function isAjax() { return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')); } @@ -292,7 +292,7 @@ static public function isAjax() { * @param string $format Format of the date. Any combination of mm, dd, yyyy * with single character separator between. */ - static public function is_valid_date($value, $format = 'dd.mm.yyyy'){ + public static function is_valid_date($value, $format = 'dd.mm.yyyy'){ if(strlen($value) >= 6 && strlen($format) == 10){ // find separator. Remove all other characters from $format @@ -324,7 +324,7 @@ static public function is_valid_date($value, $format = 'dd.mm.yyyy'){ * formatSearchvalue * format the search posted values before use them in the sql query */ - static public function formatSearchvalue($value) { + public static function formatSearchvalue($value) { // If is a numeric if (is_numeric ( $value )) { @@ -344,7 +344,7 @@ static public function formatSearchvalue($value) { /* * Clean the tmp folder */ - static public function cleantmp() { + public static function cleantmp() { $seconds_old = 1800; // 30 minutes old $directory = PUBLIC_PATH . "/tmp"; @@ -363,7 +363,7 @@ static public function cleantmp() { /* * Remove empty directories */ - static public function removeEmptySubFolders($path){ + public static function removeEmptySubFolders($path){ $empty=true; foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file){ @@ -374,7 +374,7 @@ static public function removeEmptySubFolders($path){ } // Check if the string is an email - static public function isEmail($email) { + public static function isEmail($email) { return preg_match ( '|^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$|i', $email ); } @@ -384,7 +384,7 @@ static public function isEmail($email) { * @param string $strText, $intLength, $strTrail * @return string $CropSentence */ - static public function CropSentence($strText, $intLength, $strTrail) { + public static function CropSentence($strText, $intLength, $strTrail) { $wsCount = 0; $intTempSize = 0; $intTotalLen = 0; @@ -437,7 +437,7 @@ static public function CropSentence($strText, $intLength, $strTrail) { * @param string $childrenKey index for children, in case $flattenChildren was set to false. Defaults to "@children" * @return array the resulting array. */ - static public function simpleXMLToArray($xml, $flattenValues = true, $flattenAttributes = true, $flattenChildren = true, $valueKey = '@value', $attributesKey = '@attributes', $childrenKey = '@children') { + public static function simpleXMLToArray($xml, $flattenValues = true, $flattenAttributes = true, $flattenChildren = true, $valueKey = '@value', $attributesKey = '@attributes', $childrenKey = '@children') { $return = array (); @@ -510,7 +510,7 @@ static public function simpleXMLToArray($xml, $flattenValues = true, $flattenAtt * @param boolean $considerHtml If true, HTML tags would be handled correctly * @return string Trimmed string. */ - static public function truncate($text, $length = 100, $ending = '...', $exact = true, $considerHtml = false) { + public static function truncate($text, $length = 100, $ending = '...', $exact = true, $considerHtml = false) { if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text if (strlen ( preg_replace ( '/<.*?>/', '', $text ) ) <= $length) { @@ -605,7 +605,7 @@ static public function truncate($text, $length = 100, $ending = '...', $exact = * Delete the directory selected and all its subfolders * @param string $dir */ - static public function delTree($dir) { + public static function delTree($dir) { $files = glob ( $dir . '*', GLOB_MARK ); if (is_array ( $files )) { foreach ( $files as $file ) { @@ -635,7 +635,7 @@ static public function delTree($dir) { * @param string/array $attachments * @return boolean|multitype:unknown NULL */ - static public function SendEmail($from, $to, $bcc = NULL, $subject, $body, $html = false, $inreplyto = NULL, $attachments = NULL, $replyto = NULL) { + public static function SendEmail($from, $to, $bcc = NULL, $subject, $body, $html = false, $inreplyto = NULL, $attachments = NULL, $replyto = NULL) { $transport = null; $config = array (); @@ -734,7 +734,7 @@ static public function SendEmail($from, $to, $bcc = NULL, $subject, $body, $html * getEmailTemplate * Get the email template from the filesystem */ - static public function getEmailTemplate($template) { + public static function getEmailTemplate($template) { $email = false; $subject = ""; $locale = Zend_Registry::get ( 'Zend_Locale' ); @@ -780,7 +780,7 @@ static public function getEmailTemplate($template) { return $email; } - static public function cvsExport($recordset) { + public static function cvsExport($recordset) { $cvs = ""; @unlink ( "documents/export.csv" ); if (! empty ( $recordset ) && is_array ( $recordset )) { @@ -797,7 +797,7 @@ static public function cvsExport($recordset) { return $cvs; } - static public function whoisInfo($domain) { + public static function whoisInfo($domain) { $uri = "http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=$domain"; $client = new Zend_Http_Client ( $uri ); try { @@ -807,7 +807,7 @@ static public function whoisInfo($domain) { } } - function in_arrayi($needle, $haystack) { + public static function in_arrayi($needle, $haystack) { return in_array ( strtolower ( $needle ), array_map ( 'strtolower', $haystack ) ); } @@ -818,7 +818,7 @@ function in_arrayi($needle, $haystack) { * @param $format Zend_date format * @return date formatted by the locale setting */ - static public function formatDateOut($dbindata, $format=Zend_Date::DATE_MEDIUM) { + public static function formatDateOut($dbindata, $format=Zend_Date::DATE_MEDIUM) { if (empty ( $dbindata )) return false; @@ -834,7 +834,7 @@ static public function formatDateOut($dbindata, $format=Zend_Date::DATE_MEDIUM) * @param string $dboutdata * @return string Y-m-d H:i:s */ - static public function formatDateIn($dboutdata) { + public static function formatDateIn($dboutdata) { if (empty ( $dboutdata )) return null; @@ -852,7 +852,7 @@ static public function formatDateIn($dboutdata) { * @param integer $yr * @return boolean|Zend_Date */ - function add_date($givendate, $day = 0, $mth = 0, $yr = 0) { + public static function add_date($givendate, $day = 0, $mth = 0, $yr = 0) { if (empty ( $givendate )) return false; @@ -883,7 +883,7 @@ function add_date($givendate, $day = 0, $mth = 0, $yr = 0) { * Create a flat array starting from a multidimensional array * @return array */ - function array_flatten($a, $f = array()) { + public static function array_flatten($a, $f = array()) { if (! $a || ! is_array ( $a )) return $f; foreach ( $a as $k => $v ) { @@ -900,7 +900,7 @@ function array_flatten($a, $f = array()) { * Get the value of a specific key in a multidimensional array * @var string */ - function search($keys, $search, &$results) { + public static function search($keys, $search, &$results) { foreach ( $search as $k => $v ) { if (is_array ( $v )) { self::search ( $keys, $v, $results ); From 703655b5393aa78cd32360303cf7a06a07ba8260 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 14:45:24 +0100 Subject: [PATCH 03/11] Fix productname shown on services tab in customer section --- application/modules/admin/controllers/CustomersController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/modules/admin/controllers/CustomersController.php b/application/modules/admin/controllers/CustomersController.php index 1c1dd775..b77fc13d 100644 --- a/application/modules/admin/controllers/CustomersController.php +++ b/application/modules/admin/controllers/CustomersController.php @@ -284,7 +284,8 @@ private function servicesGrid() { try { if (isset ( $request->id ) && is_numeric ( $request->id )) { // In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created. - $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' ); + //$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' ); + $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.description as productname' ); if ($rs) { return array ('name' => 'services', 'records' => $rs, 'edit' => array ('controller' => 'services', 'action' => 'edit' ), 'pager' => true ); } From 89dfa000e99468be00269783ba4d6288798ee2e7 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 15:20:08 +0100 Subject: [PATCH 04/11] More field shown on service tab --- application/modules/admin/controllers/CustomersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/modules/admin/controllers/CustomersController.php b/application/modules/admin/controllers/CustomersController.php index b77fc13d..cdf8dc75 100644 --- a/application/modules/admin/controllers/CustomersController.php +++ b/application/modules/admin/controllers/CustomersController.php @@ -285,7 +285,7 @@ private function servicesGrid() { if (isset ( $request->id ) && is_numeric ( $request->id )) { // In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created. //$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' ); - $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.description as productname' ); + $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.order_id as orderid, oi.date_start as datestart, oi.date_end as dateend, oi.description as productname' ); if ($rs) { return array ('name' => 'services', 'records' => $rs, 'edit' => array ('controller' => 'services', 'action' => 'edit' ), 'pager' => true ); } From b98176dfb425a0467ebb7c9e8bfa65d8eb8ff91d Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 16:00:02 +0100 Subject: [PATCH 05/11] Disabled product rename if sold OrderItems::ProductsInOrdersItems conveted to static --- application/models/OrdersItems.php | 2 +- application/models/Products.php | 53 ++++++++++--------- .../admin/controllers/CustomersController.php | 2 +- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/application/models/OrdersItems.php b/application/models/OrdersItems.php index 67f227aa..e3e65faa 100644 --- a/application/models/OrdersItems.php +++ b/application/models/OrdersItems.php @@ -625,7 +625,7 @@ public static function CheckIfProductExist($product_id) { * Get all the orders where the product has been selected. * @return array */ - public function ProductsInOrdersItems($product_id) { + public static function ProductsInOrdersItems($product_id) { if (is_numeric ( $product_id )) { $records = Doctrine_Query::create ()->select ( 'DATE_FORMAT(oi.date_start, "%d/%m/%Y") as date, CONCAT(c.firstname, " ", c.lastname, " - ", c.company) as customer, oi.quantity, oi.order_id as orderid, s.status as status' ) ->from ( 'OrdersItems oi' ) diff --git a/application/models/Products.php b/application/models/Products.php index 939b0d9e..0e1e0f92 100644 --- a/application/models/Products.php +++ b/application/models/Products.php @@ -190,23 +190,23 @@ public static function saveAll($id, $params, $locale = 1) { } } if(is_array($params)){ - $products->updated_at = date('Y-m-d H:i:s'); - $products->categories = ! empty ( $params ['categories'] ) ? $params ['categories'] : null; - $products->uri = ! empty ( $params ['uri'] ) ? Shineisp_Commons_UrlRewrites::format ( $params ['uri'] ) : Shineisp_Commons_UrlRewrites::format ( $params ['name'] ); - $products->cost = $params ['cost']; - $products->price_1 = $params ['price_1']; - $products->setupfee = $params ['setupfee']; - $products->enabled = $params ['enabled'] == 1 ? 1 : 0; - $products->iscomparable = !empty($params ['iscomparable']) ? 1 : 0; - $products->tax_id = !empty($params ['tax_id']) ? $params ['tax_id'] : NULL; - $products->type = !empty($params ['type']) ? $params ['type'] : "generic"; - $products->blocks = !empty($params ['blocks']) ? $params ['blocks'] : NULL; - $products->group_id = !empty($params ['group_id']) ? $params ['group_id'] : NULL; - $products->position = !empty($params ['position']) ? $params ['position'] : NULL; - $products->setup = !empty($params ['setup']) ? $params ['setup'] : NULL; + $products->updated_at = date('Y-m-d H:i:s'); + $products->categories = ! empty ( $params ['categories'] ) ? $params ['categories'] : null; + $products->uri = ! empty ( $params ['uri'] ) ? Shineisp_Commons_UrlRewrites::format ( $params ['uri'] ) : Shineisp_Commons_UrlRewrites::format ( $params ['name'] ); + $products->cost = $params ['cost']; + $products->price_1 = $params ['price_1']; + $products->setupfee = $params ['setupfee']; + $products->enabled = $params ['enabled'] == 1 ? 1 : 0; + $products->iscomparable = !empty($params ['iscomparable']) ? 1 : 0; + $products->tax_id = !empty($params ['tax_id']) ? $params ['tax_id'] : NULL; + $products->type = !empty($params ['type']) ? $params ['type'] : "generic"; + $products->blocks = !empty($params ['blocks']) ? $params ['blocks'] : NULL; + $products->group_id = !empty($params ['group_id']) ? $params ['group_id'] : NULL; + $products->position = !empty($params ['position']) ? $params ['position'] : NULL; + $products->setup = !empty($params ['setup']) ? $params ['setup'] : NULL; $products->ishighlighted = !empty($params ['ishighlighted']) ? 1 : 0; - $products->showonrss = !empty($params ['showonrss']) ? 1 : 0; - $products->external_id = !empty($params ['external_id']) ? $params ['external_id'] : NULL; + $products->showonrss = !empty($params ['showonrss']) ? 1 : 0; + $products->external_id = !empty($params ['external_id']) ? $params ['external_id'] : NULL; // Save the data $products->save (); @@ -214,19 +214,24 @@ public static function saveAll($id, $params, $locale = 1) { // Save the product attributes ProductsAttributesIndexes::saveAll ( $params, $product_id ); + $Pdata = ProductsData::findbyProductID ( $product_id, $locale ); if (empty ( $Pdata )) { - $Pdata = new ProductsData (); + $Pdata = new ProductsData (); + } + + //* Product name can not be changed if product is sold + if ( ! (bool)OrdersItems::CheckIfProductExist($product_id) ) { + $Pdata->name = $params ['name']; } - $Pdata->name = $params ['name']; - $Pdata->nickname = $params ['nickname']; + $Pdata->nickname = $params ['nickname']; $Pdata->shortdescription = $params ['shortdescription']; - $Pdata->description = $params ['description']; - $Pdata->metakeywords = $params ['metakeywords']; - $Pdata->metadescription = $params ['metadescription']; - $Pdata->product_id = $product_id; - $Pdata->language_id = $locale; + $Pdata->description = $params ['description']; + $Pdata->metakeywords = $params ['metakeywords']; + $Pdata->metadescription = $params ['metadescription']; + $Pdata->product_id = $product_id; + $Pdata->language_id = $locale; $Pdata->save (); // Create the price tranches diff --git a/application/modules/admin/controllers/CustomersController.php b/application/modules/admin/controllers/CustomersController.php index cdf8dc75..3d1f99c4 100644 --- a/application/modules/admin/controllers/CustomersController.php +++ b/application/modules/admin/controllers/CustomersController.php @@ -285,7 +285,7 @@ private function servicesGrid() { if (isset ( $request->id ) && is_numeric ( $request->id )) { // In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created. //$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' ); - $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.order_id as orderid, oi.date_start as datestart, oi.date_end as dateend, oi.description as productname' ); + $rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.order_id as orderid, oi.date_start as datestart, oi.date_end as dateend, pd.name as productname' ); if ($rs) { return array ('name' => 'services', 'records' => $rs, 'edit' => array ('controller' => 'services', 'action' => 'edit' ), 'pager' => true ); } From 70c0ef36b81dd28e0f4dc83a6607e4efb44aa728 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 16:08:26 +0100 Subject: [PATCH 06/11] Product name filed set to readonly when product is sold --- application/modules/admin/controllers/ProductsController.php | 1 + .../modules/admin/views/scripts/products/applicantform.phtml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/application/modules/admin/controllers/ProductsController.php b/application/modules/admin/controllers/ProductsController.php index bcab9aaa..7a8bad8c 100644 --- a/application/modules/admin/controllers/ProductsController.php +++ b/application/modules/admin/controllers/ProductsController.php @@ -267,6 +267,7 @@ public function editAction() { $this->view->mex = $this->getRequest ()->getParam ( 'mex' ); $this->view->mexstatus = $this->getRequest ()->getParam ( 'status' ); $this->view->orders = $orders; + $this->view->isSold = (bool)OrdersItems::CheckIfProductExist($id); $this->view->form = $form; $this->render ( 'applicantform' ); diff --git a/application/modules/admin/views/scripts/products/applicantform.phtml b/application/modules/admin/views/scripts/products/applicantform.phtml index 6e9121b8..afa8e069 100644 --- a/application/modules/admin/views/scripts/products/applicantform.phtml +++ b/application/modules/admin/views/scripts/products/applicantform.phtml @@ -164,5 +164,9 @@ \ No newline at end of file From 4b21703a6a53ae3e9183853b5f90c4bb18840b87 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 16:55:33 +0100 Subject: [PATCH 07/11] Show always all item menu. Open the item menu request on reload page. --- .../modules/admin/views/helpers/Menu.php | 36 +++++++++++++++++-- public/skins/admin/base/js/master.js | 19 ++++++++-- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/application/modules/admin/views/helpers/Menu.php b/application/modules/admin/views/helpers/Menu.php index df22bfb7..beb8b8a8 100644 --- a/application/modules/admin/views/helpers/Menu.php +++ b/application/modules/admin/views/helpers/Menu.php @@ -59,20 +59,52 @@ public function menu() { /** * createMenu * Create the menu + * * @param unknown_type $parent */ private function createMenu($parent) { $children = Navigation::getParent ( $parent ); $items = array (); + /* JAY - 20130328 - GUEST + * Get the RequestURI to show item + * ***/ + $request = Zend_Controller_Front::getInstance()->getRequest(); + $linkActive = $request->getRequestUri(); + // END + if (is_array ( $children )) { foreach ( $children as $row ) { if($row['parent_id']){ - $link = ! empty ( $row ['url'] ) ? $row ['url'] : "/"; + $link = ! empty ( $row ['url'] ) ? $row ['url'] : "/"; }else{ $link = "#"; } - $items [] = "
  • " . $this->translation->translate($row ['label']) . "" . $this->createMenu ( $row ['id'] ) . "
  • "; + + /* JAY - 20130328 GUEST + * Add class 'showall' to active item on reload of page. + * *****/ + $showall = ""; + if( $linkActive == $link ) { + $showall = "showall"; + } else { + //Try to remove action maybe I've default action + $path = explode('/',$linkActive); + if( count($path) > 1 ) { + array_pop($path); + $tryLinkActive = implode('/',$path); + if( $tryLinkActive == $link ) { + $showall = "showall"; + } + } + } + + $items [] = ' +
  • + + '.$this->translation->translate($row ['label']).' + '.$this->createMenu ( $row ['id'] ).' +
  • '; } } diff --git a/public/skins/admin/base/js/master.js b/public/skins/admin/base/js/master.js index 326b1eea..e03ec238 100755 --- a/public/skins/admin/base/js/master.js +++ b/public/skins/admin/base/js/master.js @@ -125,6 +125,12 @@ var SLAB = (function($, window, undefined) { $(this).find('a:first').prepend(''); } }); + + /* Show active item on reload page */ + $('#sidebar_menu LI.showall').each(function(){ + $(this).parent().show(); + $(this).parent().parent().addClass('expanded'); + }) $('#sidebar_menu a').live('click', function() { var el = $(this); @@ -133,13 +139,22 @@ var SLAB = (function($, window, undefined) { if (ul.length) { if (ul.is(':hidden')) { + /* JAY - 20130328 - GUEST + * Close all submenu opened */ + $('#sidebar_menu LI.item UL').hide(); + $('#sidebar_menu LI.item').each(function(){ + $(this).removeClass('expanded') + }); + //END + li.addClass('expanded'); - + /* JAY - 20130328 - GUEST + * Show always other items not selected li.siblings('li').each(function() { if ($(this).attr('id') !== 'sidebar_menu_home') { $(this).hide(); } - }); + });*/ ul.show(); } From b5f0ca84b92d3be2c9b61d82f49a58bb59f89170 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 17:21:11 +0100 Subject: [PATCH 08/11] UUID and SKU support for Products --- .../migrations/1364484670_version18.php | 20 +++++++++++++++++++ .../migrations/1364487102_version19.php | 17 ++++++++++++++++ application/configs/schema.yml | 4 ++++ application/models/Products.php | 6 ++++++ application/models/generated/BaseProducts.php | 10 ++++++++++ .../admin/controllers/ProductsController.php | 1 - .../modules/admin/forms/ProductsForm.php | 7 +++++++ .../scripts/products/applicantform.phtml | 1 + library/Shineisp/Commons/Uuid.php | 12 +++++++++++ 9 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 application/configs/migrations/1364484670_version18.php create mode 100644 application/configs/migrations/1364487102_version19.php create mode 100644 library/Shineisp/Commons/Uuid.php diff --git a/application/configs/migrations/1364484670_version18.php b/application/configs/migrations/1364484670_version18.php new file mode 100644 index 00000000..51a43fde --- /dev/null +++ b/application/configs/migrations/1364484670_version18.php @@ -0,0 +1,20 @@ +addColumn('products', 'uuid', 'varbinary', '16', array( + )); + $this->addColumn('products', 'sku', 'string', '25', array( + )); + } + + public function down() + { + $this->removeColumn('products', 'uuid'); + $this->removeColumn('products', 'sku'); + } +} \ No newline at end of file diff --git a/application/configs/migrations/1364487102_version19.php b/application/configs/migrations/1364487102_version19.php new file mode 100644 index 00000000..8e45507a --- /dev/null +++ b/application/configs/migrations/1364487102_version19.php @@ -0,0 +1,17 @@ +changeColumn('products', 'uuid', 'string', '40', array( + )); + } + + public function down() + { + + } +} \ No newline at end of file diff --git a/application/configs/schema.yml b/application/configs/schema.yml index d47d4684..ab0abf96 100644 --- a/application/configs/schema.yml +++ b/application/configs/schema.yml @@ -2177,6 +2177,10 @@ Products: unsigned: false primary: true autoincrement: true + uuid: + type: string(40) + sku: + type: string(25) uri: type: string(150) notnull: true diff --git a/application/models/Products.php b/application/models/Products.php index 0e1e0f92..3d644c1e 100644 --- a/application/models/Products.php +++ b/application/models/Products.php @@ -178,6 +178,11 @@ public static function saveAll($id, $params, $locale = 1) { }else{ $products->inserted_at = date('Y-m-d H:i:s'); } + + // Product UUID is missing, generate a new one + if ( empty($products->uuid) ) { + $products->uuid = Shineisp_Commons_Uuid::generate(); + } try { if(!empty($_FILES ['attachments'])){ @@ -193,6 +198,7 @@ public static function saveAll($id, $params, $locale = 1) { $products->updated_at = date('Y-m-d H:i:s'); $products->categories = ! empty ( $params ['categories'] ) ? $params ['categories'] : null; $products->uri = ! empty ( $params ['uri'] ) ? Shineisp_Commons_UrlRewrites::format ( $params ['uri'] ) : Shineisp_Commons_UrlRewrites::format ( $params ['name'] ); + $products->sku = ! empty ( $params ['sku'] ) ? $params ['sku'] : ''; $products->cost = $params ['cost']; $products->price_1 = $params ['price_1']; $products->setupfee = $params ['setupfee']; diff --git a/application/models/generated/BaseProducts.php b/application/models/generated/BaseProducts.php index 054bbbff..ecf0ebad 100644 --- a/application/models/generated/BaseProducts.php +++ b/application/models/generated/BaseProducts.php @@ -8,6 +8,8 @@ * This class has been auto-generated by the Doctrine ORM Framework * * @property integer $product_id + * @property string $uuid + * @property string $sku * @property string $uri * @property timestamp $inserted_at * @property timestamp $updated_at @@ -58,6 +60,14 @@ public function setTableDefinition() 'autoincrement' => true, 'length' => '4', )); + $this->hasColumn('uuid', 'string', 40, array( + 'type' => 'string', + 'length' => '40', + )); + $this->hasColumn('sku', 'string', 25, array( + 'type' => 'string', + 'length' => '25', + )); $this->hasColumn('uri', 'string', 150, array( 'type' => 'string', 'notnull' => true, diff --git a/application/modules/admin/controllers/ProductsController.php b/application/modules/admin/controllers/ProductsController.php index 7a8bad8c..fe7b49c4 100644 --- a/application/modules/admin/controllers/ProductsController.php +++ b/application/modules/admin/controllers/ProductsController.php @@ -227,7 +227,6 @@ public function editAction() { $rs = $this->products->getAllInfo ( $id, $this->session->langid ); if (! empty ( $rs )) { - // Join the translated data information to populate the form $data = !empty($rs['ProductsData'][0]) ? $rs['ProductsData'][0] : array(); $rs = array_merge($rs, $data); diff --git a/application/modules/admin/forms/ProductsForm.php b/application/modules/admin/forms/ProductsForm.php index f00d46c3..b72c5ee8 100644 --- a/application/modules/admin/forms/ProductsForm.php +++ b/application/modules/admin/forms/ProductsForm.php @@ -29,6 +29,13 @@ public function init() 'decorators' => array('Composite'), 'class' => 'text-input large-input' )); + + $this->addElement('text', 'sku', array( + 'filters' => array('StringTrim'), + 'label' => 'SKU', + 'decorators' => array('Composite'), + 'class' => 'text-input large-input' + )); $this->addElement('textarea', 'shortdescription', array( 'filters' => array('StringTrim'), diff --git a/application/modules/admin/views/scripts/products/applicantform.phtml b/application/modules/admin/views/scripts/products/applicantform.phtml index afa8e069..210f4731 100644 --- a/application/modules/admin/views/scripts/products/applicantform.phtml +++ b/application/modules/admin/views/scripts/products/applicantform.phtml @@ -55,6 +55,7 @@
    + sku->render()?> type->render()?> group_id->render() ?> name->render() ?> diff --git a/library/Shineisp/Commons/Uuid.php b/library/Shineisp/Commons/Uuid.php new file mode 100644 index 00000000..bde58dc5 --- /dev/null +++ b/library/Shineisp/Commons/Uuid.php @@ -0,0 +1,12 @@ + Date: Thu, 28 Mar 2013 17:28:27 +0100 Subject: [PATCH 09/11] Some methods converted to static --- application/models/Navigation.php | 2 +- library/Shineisp/Commons/Contents.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/models/Navigation.php b/application/models/Navigation.php index 9be4ecee..6608ae01 100644 --- a/application/models/Navigation.php +++ b/application/models/Navigation.php @@ -94,7 +94,7 @@ public static function CreateMenu($items, $parent_id = 0, $level = 0) { * GetItems * Get all the childs reading the main array */ - private function GetItems($items, $parent_id) { + public static function GetItems($items, $parent_id) { $tmp_array = array (); for($i = 0; $i < count ( $items ); $i ++) { if ($items [$i] ['parent_id'] == $parent_id) { diff --git a/library/Shineisp/Commons/Contents.php b/library/Shineisp/Commons/Contents.php index ba84ad9b..9e873660 100644 --- a/library/Shineisp/Commons/Contents.php +++ b/library/Shineisp/Commons/Contents.php @@ -17,7 +17,7 @@ class Shineisp_Commons_Contents { * @param string $text * @return array */ - public function getAllBlocks($text) { + public static function getAllBlocks($text) { preg_match_all( '(.*{block(.+)}.*)Ui', $text, $matches ); return $matches; } @@ -27,7 +27,7 @@ public function getAllBlocks($text) { * get all the modules within a long text * @param string $text */ - public function getAllModules($text) { + public static function getAllModules($text) { preg_match_all( '(.*{module(.+)}.*)Ui', $text, $matches ); return $matches; } @@ -42,7 +42,7 @@ public function getAllModules($text) { * @param string $text * @return string */ - public function chkModule($text, $locale="en_US") { + public static function chkModule($text, $locale="en_US") { // Get all the blocks in the whole text $modules = self::getAllModules($text); @@ -109,7 +109,7 @@ public function chkModule($text, $locale="en_US") { * @param string $text * @return string */ - public function chkCMSBlocks($text, $locale="en_US") { + public static function chkCMSBlocks($text, $locale="en_US") { $languageID = Languages::get_language_id($locale); // Get all the blocks in the whole text From 4f2f673dfdabf5e2af12a8d94627e64532571eb2 Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 17:30:00 +0100 Subject: [PATCH 10/11] More fixes about static methods --- application/models/ProductsCategories.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/models/ProductsCategories.php b/application/models/ProductsCategories.php index 1663a254..a8f75584 100644 --- a/application/models/ProductsCategories.php +++ b/application/models/ProductsCategories.php @@ -327,7 +327,7 @@ public static function pager($dq, $rows=10){ * $categories = 1/2/5 * @params string $categories */ - public function getGoogleCategories($categories) { + public static function getGoogleCategories($categories) { $cats = array (); $i = 0; $categories = explode ( "/", $categories ); @@ -348,7 +348,7 @@ public function getGoogleCategories($categories) { * get all the categories information by categories ID * $categories = 1/2/5 */ - public function getCategoriesInfo($categories) { + public static function getCategoriesInfo($categories) { $cats = array (); $i = 0; $categories = explode ( "/", $categories ); From 6b5c51d2668f85ad7b1160b1c5a1c056a30e30ef Mon Sep 17 00:00:00 2001 From: "GUEST.it s.r.l" Date: Thu, 28 Mar 2013 17:42:38 +0100 Subject: [PATCH 11/11] Check item menu active from controller. Change style to item menu opened. --- .../modules/admin/views/helpers/Menu.php | 53 ++++++++++++++++--- public/skins/admin/base/css/site.css | 8 ++- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/application/modules/admin/views/helpers/Menu.php b/application/modules/admin/views/helpers/Menu.php index beb8b8a8..6906b1e6 100644 --- a/application/modules/admin/views/helpers/Menu.php +++ b/application/modules/admin/views/helpers/Menu.php @@ -40,12 +40,37 @@ public function menu() { if($identity){ if(AdminPermissions::isAllowed($identity, "admin", "settings")){ + /* JAY - 20130328 GUEST + * Add class 'showall' to active item on reload of page. + * *****/ + $request = Zend_Controller_Front::getInstance()->getRequest(); + $linkActive = $request->getRequestUri(); + $configuration = SettingsGroups::getlist (); $data .= "
  • "; $data .= "".$this->translation->translate('Configuration').""; $data .= "
      "; + $showall = ""; foreach ($configuration as $id => $item){ - $data .= "
    • " . $this->translation->translate($item) . "
    • "; + $showall = ""; + $tryLink = '/admin/settings'; + $path = explode('/',$linkActive); + $cpath = count($path); + if( $cpath > 1 ) { + if( $cpath > 2 ) { + for( $i=3; $i < $cpath; $i++) { + array_pop($path); + } + } + + + $tryLinkActive = implode('/',$path); + if( $tryLinkActive == $tryLink ) { + $showall = "showall"; + } + } + + $data .= "
    • " . $this->translation->translate($item) . "
    • "; } $data .= ""; $data .= "
    "; @@ -88,12 +113,28 @@ private function createMenu($parent) { if( $linkActive == $link ) { $showall = "showall"; } else { - //Try to remove action maybe I've default action - $path = explode('/',$linkActive); - if( count($path) > 1 ) { - array_pop($path); + //Try to remove action + $pathLink = explode('/',$link); + $cpathLink = count( $pathLink ); + if( $cpathLink > 3 ) { + for( $i=4; $i<=$cpathLink; $i++){ + array_pop($pathLink); + } + + } + $tryLink = implode('/',$pathLink); + $path = explode('/',$linkActive); + $cpath = count($path); + if( $cpath > 1 ) { + if( $cpath > 2 ) { + for( $i=3; $i < $cpath; $i++) { + array_pop($path); + } + } + + $tryLinkActive = implode('/',$path); - if( $tryLinkActive == $link ) { + if( $tryLinkActive == $tryLink ) { $showall = "showall"; } } diff --git a/public/skins/admin/base/css/site.css b/public/skins/admin/base/css/site.css index bc66386e..6535a2c7 100755 --- a/public/skins/admin/base/css/site.css +++ b/public/skins/admin/base/css/site.css @@ -363,7 +363,7 @@ table.horiz tr td:first-child { background: #eee url(/skins/admin/base/images/ui/menu_expanded.png) repeat-x left bottom; background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #eee), color-stop(1, #fff)); background: -moz-linear-gradient(top center, #eee 0%, #fff 100%); - color: #ccc; + color: #000; text-shadow: #fff 0 1px 0; } @@ -492,4 +492,8 @@ ul.stats li { ul.stats li strong, ul.stats li small, ul.stats li span { display: block; text-align: center; -} \ No newline at end of file +} + +#sidebar_menu .showall{ + background-color:#e0f0ff; +}