<?php

/**
 * Manage Products Measurements
 * @author IT TEAM BONOFACTUM
 * @created Apr 13, 2015 11:50:07 AM 
 */
use_class('CategoryTop');
use_class('Category');
use_class('ProductMeasurement');
$class_pmr = new ProductMeasurement();
$reload_list = false;
$session_page = 'products-measurements';
if (!isset($_SESSION[$session_page]['catid']) || $_SESSION[$session_page]['catid'] == '') {
    $MEASUREMENTCATID = isset($_POST['cat_id']) ? tep_db_prepare_input($_POST['cat_id']) : '';
} else {
    $MEASUREMENTCATID = $_SESSION[$session_page]['catid'];
}
//SUBMIT ACTION
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADMEASUREMENTS') {
        $cat_id = tep_db_prepare_input($_POST['cat_id']);
        $_SESSION[$session_page]['catid'] = $cat_id;
        $languages_id = 1;
        $measurements = $class_pmr->getList($cat_id, $languages_id, true);
        echo utf8_encode($measurements);
        exit;
    } elseif ($_POST['me_action'] == 'MEASUREMENTSAVE') {
        $category_id = $MEASUREMENTCATID;
        $name_en = tep_db_prepare_input($_POST['name'][1]);
        $measurements_id = tep_db_prepare_input($_POST['measurements_id']);
Example #2
0
 /**
  * Display product measurement (L x W x H) in centimeters or articles measurement with flexible format
  * @param int $language_id
  * @param int $articles_id
  * @param string $unit_separator
  * @param const $format
  * @param string $dec_separator
  * @return string
  */
 public function displayMeasurement($language_id, $articles_id = '', $unit_separator = '', $format = self::FORMAT_DISPLAYMEASUREMENT_PM1, $dec_separator = '')
 {
     //TODO:
     //Move displayMeasurement for article in ProductArticle object
     //Load ProductMeasurement like OOP (must update the class first)
     //1 function shoud have only 1 return (at the bottom of the function)
     use_class('ProductMeasurement');
     $class_pmr = new ProductMeasurement();
     if ($articles_id !== '') {
         $result = '';
         $measurements_labels = array();
         $measurements_values = array();
         if ($format == self::FORMAT_DISPLAYMEASUREMENT_PM1 || $format == self::FORMAT_DISPLAYMEASUREMENT_PM2) {
             $l = $this->detail['pd2']['length'] > 0 ? $this->detail['pd2']['length'] / 10 : 0;
             $w = $this->detail['pd2']['width'] > 0 ? $this->detail['pd2']['width'] / 10 : 0;
             $h = $this->detail['pd2']['height'] > 0 ? $this->detail['pd2']['height'] / 10 : 0;
             if ($l > 10 || $w > 10 || $h > 10) {
                 $dec_number = 0;
             } else {
                 $dec_number = 1;
             }
             if ($dec_separator == '') {
                 if ($language_id == '2' || $language_id == '3') {
                     $dec_separator = ',';
                 } else {
                     $dec_separator = '.';
                 }
             }
             if ($language_id == 1) {
                 $measurements_labels[] = 'Length';
                 $measurements_labels[] = 'Width';
                 $measurements_labels[] = 'Height';
             } elseif ($language_id == 2) {
                 $measurements_labels[] = 'Länge';
                 $measurements_labels[] = 'Breite';
                 $measurements_labels[] = 'Höhe';
             } elseif ($language_id == 3) {
                 $measurements_labels[] = 'Panjang';
                 $measurements_labels[] = 'Lebar';
                 $measurements_labels[] = 'Tinggi';
             }
             $measurements_values[] = number_format($l, $dec_number, $dec_separator, '') . 'cm';
             $measurements_values[] = number_format($w, $dec_number, $dec_separator, '') . 'cm';
             $measurements_values[] = number_format($h, $dec_number, $dec_separator, '') . 'cm';
         } else {
             $measurements = Product::getOldProductArticleFunction()->getMeasurementDetail($this->id, $articles_id);
             foreach ($measurements as $msr_id => $msr_dt) {
                 $msr_desc = $class_pmr->getDescription($msr_id, $language_id);
                 $measurements_labels[$msr_id] = $msr_desc[$language_id]['name'];
                 list($msr_val, $msr_unit) = explode(' ', $msr_dt['measurements_value']);
                 if ($msr_val !== '') {
                     $measurements_values[$msr_id] = $msr_val . $unit_separator . $msr_unit;
                 } else {
                     unset($measurements_labels[$msr_val]);
                 }
             }
         }
         switch ($format) {
             case self::FORMAT_DISPLAYMEASUREMENT_PM1:
             case self::FORMAT_DISPLAYMEASUREMENT_AM1:
                 $result = implode(' x ', $measurements_labels) . ' - ' . implode(' x ', $measurements_values);
                 break;
             case self::FORMAT_DISPLAYMEASUREMENT_AM2:
                 $size_text = $this->getLengthOrSizeAsText($articles_id);
                 $result = implode(' x ', $measurements_labels) . ' - ' . $size_text . ($size_text != '' ? ' ' : '') . '(' . implode(' x ', $measurements_values) . ')';
                 break;
             case self::FORMAT_DISPLAYMEASUREMENT_PM2:
             case self::FORMAT_DISPLAYMEASUREMENT_AM3:
                 foreach ($measurements_labels as $msr_id => $msr_lbl) {
                     $result .= ($result != '' ? ', ' : '') . $msr_lbl . ' : ' . $measurements_values[$msr_id];
                 }
                 break;
             case self::FORMAT_DISPLAYMEASUREMENT_AM4:
                 $result = implode(' x ', $measurements_labels) . ': ';
                 $dm_am4 = '';
                 foreach ($this->articles as $aid => $article) {
                     $dm_am4_size = $this->getLengthOrSizeAsText($aid);
                     $msr_val_temp = array();
                     foreach ($article['measurements'] as $msr_id => $msr_dt) {
                         list($msr_val, $msr_unit) = explode(' ', $msr_dt['measurements_value']);
                         $msr_val_temp[] = $msr_val . $unit_separator . $msr_unit;
                     }
                     $dm_am4_msr = implode(' x ', $msr_val_temp);
                     $dm_am4[] = "{$dm_am4_size} ({$dm_am4_msr})";
                 }
                 $result .= implode('; ', $dm_am4);
                 break;
         }
         return $result;
     } else {
         $l = $this->detail['pd2']['length'] > 0 ? $this->detail['pd2']['length'] / 10 : 0;
         $w = $this->detail['pd2']['width'] > 0 ? $this->detail['pd2']['width'] / 10 : 0;
         $h = $this->detail['pd2']['height'] > 0 ? $this->detail['pd2']['height'] / 10 : 0;
         if ($l > 10 || $w > 10 || $h > 10) {
             $dec_number = 0;
         } else {
             $dec_number = 1;
         }
         if ($language_id == '2' || $language_id == '3') {
             $dec_separator = ',';
         } else {
             $dec_separator = '.';
         }
         $measurement = array();
         $measurement[] = number_format($l, $dec_number, $dec_separator, '');
         $measurement[] = number_format($w, $dec_number, $dec_separator, '');
         $measurement[] = number_format($h, $dec_number, $dec_separator, '');
         //return implode(' x ', $measurement) . ' cm';
         return implode(' x ', $measurement);
     }
 }
/**
 * Description of productdetaildescription2
 *
 * @author IT TEAM BONOFACTUM
 * @created May 29, 2013 5:11:23 PM
 */
use_class('Product');
use_class('products_articles');
use_class('products_brand');
use_class('ProductMeasurement');
use_class('products_minierp');
use_class('elements_attributes');
$class_pa = new products_articles();
$class_pb = new products_brand();
$class_pmr = new ProductMeasurement();
$class_pm = new products_minierp();
$class_ea = new elements_attributes();
$products_id = tep_db_prepare_input($_GET['id']);
$product = new Product($products_id);
/* TODO: @deprecated Remove this because products description not use this.
$clasp_type = array();
$clasp_type[] = '';
$clasp_type[] = 'Agraffe';
$clasp_type[] = 'Bajonette Clasp';
$clasp_type[] = 'Clasp With Safety';
$clasp_type[] = 'Collier Clasp';
$clasp_type[] = 'Cross Clasp';
$clasp_type[] = 'Fold over clasp';
$clasp_type[] = 'Jewellery box clasp';
$clasp_type[] = 'Lobster claw clasp';