示例#1
0
 /**
  * Returns a Pricelist with properties taken from the posted data
  *
  * Backend use only.  Takes its arguments directly from the form values.
  * If no form has been posted, returns null.
  * @global  array       $_ARRAYLANG
  * @return  Pricelist                 The Pricelist on success,
  *                                    null otherwise
  */
 static function getFromPost()
 {
     global $_ARRAYLANG;
     if (empty($_POST['bsubmit'])) {
         return null;
     }
     $list_id = isset($_POST['list_id']) ? intval($_POST['list_id']) : (isset($_GET['list_id']) ? intval($_GET['list_id']) : null);
     $objList = self::getById($list_id);
     if (!$objList) {
         $objList = new PriceList(null);
     }
     $objList->name(empty($_POST['name']) ? $_ARRAYLANG['TXT_NO_NAME'] : $_POST['name']);
     $objList->lang_id(empty($_POST['lang_id']) ? null : $_POST['lang_id']);
     $objList->border(!empty($_POST['border']));
     $objList->header(!empty($_POST['header']));
     $objList->header_left(contrexx_input2raw($_POST['header_left']));
     $objList->header_right(contrexx_input2raw($_POST['header_right']));
     $objList->footer(!empty($_POST['footer']));
     $objList->footer_left(contrexx_input2raw($_POST['footer_left']));
     $objList->footer_right(contrexx_input2raw($_POST['footer_right']));
     $category_ids = '';
     if (empty($_POST['category_all']) && !empty($_POST['category_id'])) {
         foreach ($_POST['category_id'] as $category_id) {
             $category_ids .= ($category_ids ? ',' : '') . contrexx_input2raw($category_id);
         }
     }
     // Both if no or all categories were selected, select all.
     if (empty($category_ids)) {
         $category_ids = '*';
     }
     $objList->category_ids($category_ids);
     return $objList;
 }
示例#2
0
 /**
  * Edit a pricelist
  * @global  ADOConnection   $objDatabase
  * @global  array           $_ARRAYLANG
  * @return  boolean                         True on success, false otherwise
  */
 static function view_pricelist_edit()
 {
     global $_ARRAYLANG;
     $list_id = null;
     $objList = PriceList::getFromPost();
     if ($objList) {
         $result = $objList->store();
         if ($result) {
             if (isset($_REQUEST['list_id'])) {
                 unset($_REQUEST['list_id']);
             }
             //die("Showing lists");
             return self::view_pricelists();
         }
     }
     $list_id = isset($_GET['list_id']) ? $_GET['list_id'] : null;
     $objList = PriceList::getById($list_id);
     if (!$objList) {
         $objList = new PriceList(null);
     }
     $list_id = $objList->id();
     self::$objTemplate->loadTemplateFile("module_shop_pricelist_details.html");
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     self::$objTemplate->setVariable(array('SHOP_PRICELIST_EDIT' => $_ARRAYLANG[$list_id ? 'TXT_SHOP_PRICELIST_EDIT' : 'TXT_SHOP_PRICELIST_ADD'], 'SHOP_PRICELIST_ID' => $list_id, 'SHOP_PRICELIST_LINK_PDF' => $list_id ? PriceList::getUrl($list_id) : '', 'SHOP_PRICELIST_NAME' => $objList->name(), 'SHOP_PRICELIST_LANGUAGE_MENUOPTIONS' => \Html::getOptions(\FWLanguage::getNameArray(), $objList->lang_id()), 'SHOP_PRICELIST_BORDER_CHECKED' => $objList->border() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_CHECKED' => $objList->header() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_LEFT' => $objList->header_left(), 'SHOP_PRICELIST_HEADER_RIGHT' => $objList->header_right(), 'SHOP_PRICELIST_FOOTER_CHECKED' => $objList->footer() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_FOOTER_LEFT' => $objList->footer_left(), 'SHOP_PRICELIST_FOOTER_RIGHT' => $objList->footer_right()));
     $category_ids = $objList->category_ids();
     $category_all = false;
     if (empty($category_ids) || $category_ids == '*') {
         $category_all = true;
         self::$objTemplate->setVariable('SHOP_PRICELIST_CATEGORY_ALL_CHECKED', \Html::ATTRIBUTE_CHECKED);
     }
     // Get all categories
     $arrCategories = ShopCategories::getTreeArray(true, false);
     if (empty($arrCategories)) {
         Message::warning($_ARRAYLANG['TXT_SHOP_WARNING_NO_CATEGORIES']);
     }
     $i = 0;
     foreach ($arrCategories as $objCategory) {
         $category_id = $objCategory['id'];
         $selected = $category_all || preg_match('/(?:^|,)\\s*' . $category_id . '\\s*(?:,|$)/', $category_ids);
         //DBG::log("Category ID $category_id, ".($selected ? "selected" : "NOT"));
         self::$objTemplate->setVariable(array('SHOP_CATEGORY_ID' => contrexx_raw2xhtml($category_id), 'SHOP_CATEGORY_NAME' => contrexx_raw2xhtml($objCategory['name']), 'SHOP_CATEGORY_LEVELSPACE' => str_repeat('|----', $objCategory['level']), 'SHOP_CATEGORY_DISABLED' => $category_all ? \Html::ATTRIBUTE_DISABLED : '', 'SHOP_CATEGORY_CHECKED' => $selected ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_CATEGORY_ROWCLASS' => 'row' . (++$i % 2 + 1)));
         self::$objTemplate->parse('shop_category');
     }
     return true;
 }