예제 #1
0
 function m_customOptionForm()
 {
     $libFunc = new c_libFunctions();
     #INTIALIZING TEMPLATES
     $this->ObTpl = new template();
     $this->ObTpl->set_file("optionform", $this->optionTemplate);
     $this->ObTpl->set_block("optionform", "IMG_BLK", "dspimg_blk");
     $this->ObTpl->set_block("optionform", "LINK_BLK", "dsplink_blk");
     $this->ObTpl->set_var("GRAPHICSMAINPATH", GRAPHICS_PATH);
     $this->ObTpl->set_var("TPL_VAR_SITEURL", SITE_URL);
     $this->ObTpl->set_var("TPL_SHOPURL", SITE_URL . "ecom/");
     $this->ObTpl->set_var("TPL_VAR_SEL1", "");
     $this->ObTpl->set_var("TPL_VAR_SEL2", "");
     $this->ObTpl->set_var("TPL_VAR_SEL3", "");
     $this->ObTpl->set_var("TPL_VAR_SEL4", "");
     //defining language variables
     $this->ObTpl->set_var("LANG_VAR_CUSTOMOPTTXT", LANG_CUSTOMOPTBUILD);
     $this->ObTpl->set_var("LANG_VAR_FIELDNAME", LANG_FIELDNAME);
     $this->ObTpl->set_var("LANG_VAR_DESCRIPTION", LANG_DESCRIPTION);
     $this->ObTpl->set_var("LANG_VAR_FIELDTYPE", LANG_TYPEOFTXT);
     $this->ObTpl->set_var("LANG_VAR_QUANTITYBOX", LANG_QUANTITYBOX);
     $this->ObTpl->set_var("LANG_VAR_INPUTBOX", LANG_INPUTBOX);
     $this->ObTpl->set_var("LANG_VAR_CHECKBOX", LANG_CHECKBOX);
     $this->ObTpl->set_var("LANG_VAR_TEXTAREA", LANG_TEXTAREA);
     $this->ObTpl->set_var("LANG_VAR_USESTOCK", LANG_USINGSTOCK);
     $this->ObTpl->set_var("LANG_VAR_ALLOWBACK", LANG_ALLOWBACKORDERS);
     $this->ObTpl->set_var("LANG_VAR_STOCKLVL", LANG_STOCKLVL);
     $this->ObTpl->set_var("LANG_VAR_ADDTLPRICE", LANG_ADDTLPRICE);
     $this->ObTpl->set_var("LANG_VAR_ONOFF", LANG_ONOFF);
     $this->ObTpl->set_var("LANG_VAR_OPTIMAGE", LANG_OPTIMAGE);
     /*CHECKING FOR POST VARIABLES
     		IF VARIABLES ARE SET THEN ASSIGNING THEIR VALUE TO VARIABLE SAMEVARIABLE
     		AS USED WHEN RETURNED FROM DATABASE
     		THIS THING IS USED TO REMOVE REDUNDANCY AND USE SAME FORM FOR EDIT AND INSERT*/
     if (count($_POST) > 0) {
         if (isset($this->request["cname"])) {
             $row_option[0]->vName = $this->request["cname"];
         }
         if (isset($this->request["description"])) {
             $row_option[0]->vDescription = $this->request["description"];
         }
         if (isset($this->request["type"])) {
             $row_option[0]->vType = $this->request["type"];
         }
         if (isset($this->request["use_inventory"])) {
             $row_option[0]->iUseInventory = $this->request["use_inventory"];
         }
         if (isset($this->request["backorder"])) {
             $row_option[0]->iBackorder = $this->request["backorder"];
         }
         if (isset($this->request["inventory"])) {
             $row_option[0]->iInventory = $this->request["inventory"];
         }
         if (isset($this->request["price"])) {
             $row_option[0]->fPrice = $this->request["price"];
         }
         if (isset($this->request["state"])) {
             $row_option[0]->iState = $this->request["state"];
         }
         $row_option[0]->vImage = "";
     } else {
         $row_option[0]->vName = "";
         $row_option[0]->vDescription = "";
         $row_option[0]->vType = "";
         $row_option[0]->iUseInventory = "";
         $row_option[0]->iBackorder = "";
         $row_option[0]->iInventory = "";
         $row_option[0]->fPrice = "";
         $row_option[0]->vImage = "";
         $row_option[0]->iState = "";
     }
     #IF EDIT MODE SELECTED
     if (isset($this->request['choiceid']) && !empty($this->request['choiceid'])) {
         $this->obDb->query = $this->obDb->query = "SELECT * FROM " . CHOICES . " WHERE iChoiceid_PK ='" . $this->request['choiceid'] . "'";
         $row_option = $this->obDb->fetchQuery();
         if (!isset($this->request['msg']) || empty($this->request['msg'])) {
             $this->request["tmFormatEditDate"] = $libFunc->dateFormat($row_option[0]->tmEditDate);
             $this->ObTpl->set_var("TPL_VAR_MSG", LBL_LAST_UPDATE . $this->request['tmFormatEditDate']);
         }
         if ($this->err == 1) {
             $this->ObTpl->set_var("TPL_VAR_MSG", $this->errMsg);
         }
         if ($row_option[0]->vType == "input") {
             $this->ObTpl->set_var("TPL_VAR_SEL2", "selected");
         } elseif ($row_option[0]->vType == "checkbox") {
             $this->ObTpl->set_var("TPL_VAR_SEL3", "selected");
         } elseif ($row_option[0]->vType == "textarea") {
             $this->ObTpl->set_var("TPL_VAR_SEL4", "selected");
         } else {
             $this->ObTpl->set_var("TPL_VAR_SEL1", "selected");
         }
         if ($row_option[0]->iUseInventory == 1) {
             $this->ObTpl->set_var("TPL_VAR_SELECTED1", "checked");
         } else {
             $this->ObTpl->set_var("TPL_VAR_SELECTED1", "");
         }
         if ($row_option[0]->iBackorder == 1) {
             $this->ObTpl->set_var("TPL_VAR_SELECTED2", "checked");
         } else {
             $this->ObTpl->set_var("TPL_VAR_SELECTED2", "");
         }
         if ($row_option[0]->iState == 1) {
             $this->ObTpl->set_var("TPL_VAR_SELECTED3", "checked");
         } else {
             $this->ObTpl->set_var("TPL_VAR_SELECTED3", "");
         }
         $this->ObTpl->set_var("TPL_VAR_MODE", "edit");
         $this->ObTpl->set_var("TPL_VAR_CHOICEID", $this->request['choiceid']);
         #HANDLING BLOCKS
         $this->ObTpl->set_var("TPL_VAR_LBLBUTTON", LBL_EDIT_CHOICE);
         if (file_exists($this->imagePath . "options/" . $row_option[0]->vImage) && $row_option[0]->vImage != "") {
             $this->ObTpl->set_var("TPL_VAR_IMGLBL", "Edit Image");
         } else {
             $this->ObTpl->set_var("TPL_VAR_IMGLBL", "Add Image");
         }
         $this->ObTpl->set_var("dspimg_blk", "");
         $this->ObTpl->parse("dsplink_blk", "LINK_BLK");
     } else {
         $this->ObTpl->set_var("TPL_VAR_CHOICEID", "");
         $this->ObTpl->set_var("TPL_VAR_MODE", "Add");
         $this->ObTpl->set_var("TPL_VAR_SELECTED1", "");
         $this->ObTpl->set_var("TPL_VAR_SELECTED2", "");
         $this->ObTpl->set_var("TPL_VAR_SELECTED3", "checked");
         $this->ObTpl->set_var("TPL_VAR_SEL1", "selected");
         $this->obDb->query = $this->obDb->query = "SELECT count(*) as totalCnt FROM " . CHOICES;
         $row_choice1 = $this->obDb->fetchQuery();
         if (!isset($this->request['msg'])) {
             $this->ObTpl->set_var("TPL_VAR_MSG", "Total Records " . $row_choice1[0]->totalCnt);
         } elseif ($this->err == 1) {
             $this->ObTpl->set_var("TPL_VAR_MSG", $this->errMsg);
         }
         $this->ObTpl->set_var("TPL_VAR_LBLBUTTON", LBL_ADD_CHOICE);
         $this->ObTpl->set_var("dsplink_blk", "");
         $this->ObTpl->parse("dspimg_blk", "IMG_BLK");
     }
     #ASSIGNING FORM ACTION
     $this->ObTpl->set_var("TPL_VAR_FORMURL", SITE_URL . "ecom/adminindex.php?action=ec_option.choiceadd");
     #ASSIGNING FORM VARAIABLES
     $this->ObTpl->set_var("TPL_VAR_TITLE", $libFunc->m_displayContent($row_option[0]->vName));
     $this->ObTpl->set_var("TPL_VAR_DESC", $libFunc->m_displayContent($row_option[0]->vDescription));
     $this->ObTpl->set_var("TPL_VAR_PRICE", $libFunc->m_displayContent($row_option[0]->fPrice));
     $this->ObTpl->set_var("TPL_VAR_INVENTORY", $libFunc->m_displayContent($row_option[0]->iInventory));
     return $this->ObTpl->parse("return", "optionform");
 }