public function addpriceAction() { $this->view->messages = $this->_flashMessenger->getMessages(); $this->_helper->layout->disableLayout(); $formData = array(); $formErrors = array(); $formData = $this->getRequest()->getPost(); if ($this->getRequest()->isPost() && (!empty($formData['createprice']) && $formData['createprice'] == 'Add Price')) { if (!isset($formData['country']) || trim($formData['country']) == "") { $formErrors['country'] = "Please select country "; } if (!isset($formData['language']) || trim($formData['language']) == "") { $formErrors['language'] = "Please select language"; } if (!isset($formData['price']) || trim($formData['price']) == "") { $formErrors['price'] = "Please select price"; } if (count($formErrors) == 0) { $priceId = 0; $price_error = array(); if ($this->modelBooks->isPriceExist($formData['productid'], $formData['country'], $formData['language'], '')) { //echo"<strong><font color='red'>Price already exist.</font></strong>";exit; $price_error[] = "Price already exist."; } else { if ($this->modelBooks->isGroupPriceExist($formData['productid'], $formData['country'], $formData['language'], $formData['group_price'], '')) { //echo"<strong><font color='red'>Price already exist.</font></strong>";exit; $price_error[] = "Group Price already exist."; } else { $priceData = array('product_id' => $formData['productid'], 'country_id' => $formData['country'], 'language_id' => $formData['language'], 'price' => $formData['price'], 'group_price' => $formData['group_price']); $modelPrice = new Publisher_Model_DbTable_BookPrices(); $priceId = $modelPrice->insert($priceData); } } if (empty($priceId)) { $price_error[] = "Price could not be saved."; } ?> <form name="form-add-price" id="form-add-price" method="post" onsubmit="return validate_pricing_form('form-add-price','<?php echo $createpriceURL; ?> ');"> <fieldset class="dashboard_fieldset"> <legend>Publication Store & Langauge</legend> <table width="99%" class="table-list publisher" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" colspan="2"><div id="priceoutput"></div></td> </tr> <tr> <td class="tdleftBold">Store<span class="required">*</span> : </td> <td> <?php $modelCountry = new Publisher_Model_DbTable_Books(); $countryList = $modelCountry->getCountryList(); ?> <select name="country" id="country" class="req" message="Please select country"> <option value="">Select Store</option> <?php for ($ii = 0; $ii < count($countryList); $ii++) { ?> <option value="<?php echo $countryList[$ii]['id']; ?> "><?php echo $countryList[$ii]['country']; ?> </option> <?php } ?> </select> <?php if (array_key_exists('country', $formErrors)) { echo '<div class="inline-error">' . $formErrors['country'] . '</div>'; } ?> </td> </tr> <tr> <td class="tdleftBold">Language<span class="required">*</span> : </td> <td> <?php $modelLanguage = new Publisher_Model_DbTable_Books(); $languageList = $modelLanguage->getLanguageList(); ?> <select name="language" id="language" class="req" message="Please select language"> <option value="">Select Language</option> <?php for ($ii = 0; $ii < count($languageList); $ii++) { ?> <option value="<?php echo $languageList[$ii]['id']; ?> "><?php echo $languageList[$ii]['language_name']; ?> </option> <?php } ?> </select> <?php if (array_key_exists('language', $formErrors)) { echo '<div class="inline-error">' . $formErrors['language'] . '</div>'; } ?> </td> </tr> <tr> <td class="tdleftBold">Price<span class="required">*</span> : </td> <td> <input type="text" name="price" id="price" class="req" message="Please enter price"/> <?php if (array_key_exists('price', $formErrors)) { echo '<div class="inline-error">' . $formErrors['price'] . '</div>'; } ?> </td> </tr> <tr> <td class="tdleftBold">Group Price : </td> <td> <input type="text" name="group_price" id="group_price" /> <?php if (array_key_exists('price', $formErrors)) { echo '<div class="inline-error">' . $formErrors['price'] . '</div>'; } ?> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2"> <div style="text-align:center;"> <input type="hidden" name="createprice" value="Add Price"> <input type="hidden" name="productid" id="productid" value="<?php echo $_REQUEST['productid']; ?> " /> <input type="submit" name="createprice" id="createprice" value="Add Price" class="button-Save"/> </div> </td> </tr> </table> </fieldset> </form>77777777777 <?php echo "<table width='100%' class='table-list' border='0' cellspacing='0' cellpadding='0'><tr>\n<td width='50%'><div align='left'><strong>Country</strong></div></td>\n<td width='30%'><div align='left'><strong>Language</strong></div></td>\n<td width='10%'><div align='left'><strong>Price</strong></div></td>\n<td width='20%'><div align='left'><strong>Group Price</strong></div></td>\n<td width='10%'><div align='left'><strong>Action</strong></div></td>\n</tr>"; $modelPrice = new Publisher_Model_DbTable_BookPrices(); $priceList = $modelPrice->getPriceList($formData['productid']); for ($jj = 0; $jj < count($priceList); $jj++) { $deletePriceUrl = $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'deleteprice', 'id' => $priceList[$jj]['id']), '', true); echo "<tr><td><div align='left'>"; $modelCountry = new Publisher_Model_DbTable_Books(); $countryRecord = $modelCountry->getCountryName($priceList[$jj]['country_id']); echo $countryRecord['country']; echo "</div></td><td><div align='left'>"; $modelLanguage = new Publisher_Model_DbTable_Books(); $languageRecord = $modelLanguage->getLanguageName($priceList[$jj]['language_id']); echo $languageRecord['language_name']; echo "</div></td><td><div align='left'>"; echo "\$" . $priceList[$jj]['price']; echo "</div></td><td><div align='left'>"; echo "\$" . $priceList[$jj]['group_price']; echo "</div></td><td><div align='left'>"; echo "<a class='action-icon' href='" . $deletePriceUrl . "' onclick='return deleteprice(this.href);' title='Delete'>"; echo "<img src='" . $this->view->serverUrl() . $this->view->baseUrl() . "/public/css/publisher/images/trash.gif' height='10' width='10'>"; echo "</a> "; ?> <a href="javascript:void(0);" onclick="return updateprice1('<?php echo $priceList[$jj]['id']; ?> ','<?php echo $this->view->serverUrl() . $this->view->baseUrl() . "/publisher/book/saveprice"; ?> ','<?php echo $formData['productid']; ?> ');"'<?php echo $priceList[$jj]['id']; ?> ','<?php echo $this->view->serverUrl() . $this->view->baseUrl() . "/publisher/book/saveprice"; ?> ','<?php echo $formData['productid']; ?> ');"> <img src="<?php echo $this->view->serverUrl() . $this->view->baseUrl() . "/public/css/publisher/images/icon_edit.png"; ?> " width="10" height="10"/> </a> <?php echo "</div></td></tr>"; } if (!empty($price_error)) { foreach ($price_error as $error_msg) { echo "<tr><td colspan='4'><strong><font color='red'>" . $error_msg . "</font></strong></td></tr>"; } } echo "</table>"; } } $this->view->formData = $formData; $this->view->formErrors = $formErrors; exit; }
public function addpriceAction() { $this->view->messages = $this->_flashMessenger->getMessages(); $this->_helper->layout->disableLayout(); $formData = array(); $formErrors = array(); $formData = $this->getRequest()->getPost(); if ($this->getRequest()->isPost() && (!empty($formData['createprice']) && $formData['createprice'] == 'Add Price')) { if (!isset($formData['country']) || trim($formData['country']) == "") { $formErrors['country'] = "Please select country "; } if (!isset($formData['language']) || trim($formData['language']) == "") { $formErrors['language'] = "Please select language"; } if (!isset($formData['price']) || trim($formData['price']) == "") { $formErrors['price'] = "Please select price"; } if (count($formErrors) == 0) { $priceId = 0; $price_error = array(); if ($this->modelBooks->isPriceExist($formData['productid'], $formData['country'], $formData['language'])) { //echo"<strong><font color='red'>Price already exist.</font></strong>";exit; $price_error[] = "Price already exist."; } else { if ($this->modelBooks->isGroupPriceExist($formData['productid'], $formData['country'], $formData['language'], $formData['group_price'])) { //echo"<strong><font color='red'>Price already exist.</font></strong>";exit; $price_error[] = "Group Price already exist."; } else { $priceData = array('product_id' => $formData['productid'], 'country_id' => $formData['country'], 'language_id' => $formData['language'], 'price' => $formData['price'], 'group_price' => $formData['group_price']); $modelPrice = new Publisher_Model_DbTable_BookPrices(); $priceId = $modelPrice->insert($priceData); } } if (empty($priceId)) { $price_error[] = "Price could not be saved."; } echo "<table width='100%' class='table-list' border='0' cellspacing='0' cellpadding='0'><tr>\n<td width='50%'><div align='left'><strong>Country</strong></div></td>\n<td width='30%'><div align='left'><strong>Language</strong></div></td>\n<td width='10%'><div align='left'><strong>Price</strong></div></td>\n<td width='20%'><div align='left'><strong>Group Price</strong></div></td>\n<td width='10%'><div align='left'><strong>Action</strong></div></td>\n</tr>"; $modelPrice = new Publisher_Model_DbTable_BookPrices(); $priceList = $modelPrice->getPriceList($formData['productid']); for ($jj = 0; $jj < count($priceList); $jj++) { $deletePriceUrl = $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'deleteprice', 'id' => $priceList[$jj]['id']), '', true); echo "<tr><td><div align='left'>"; $modelCountry = new Publisher_Model_DbTable_Books(); $countryRecord = $modelCountry->getCountryName($priceList[$jj]['country_id']); echo $countryRecord['country']; echo "</div></td><td><div align='left'>"; $modelLanguage = new Publisher_Model_DbTable_Books(); $languageRecord = $modelLanguage->getLanguageName($priceList[$jj]['language_id']); echo $languageRecord['language_name']; echo "</div></td><td><div align='left'>"; echo $priceList[$jj]['price']; echo "</div></td><td><div align='left'>"; echo $priceList[$jj]['group_price']; echo "</div></td><td><div align='left'>"; echo "<a class='action-icon' href='" . $deletePriceUrl . "' onclick='return deleteprice(this.href);' title='Delete'>"; echo "<img src='" . $this->view->serverUrl() . $this->view->baseUrl() . "/public/css/publisher/images/trash.gif' height='10' width='10'>"; echo "</a> "; echo "</div></td></tr>"; } if (!empty($price_error)) { foreach ($price_error as $error_msg) { echo "<tr><td colspan='4'><strong><font color='red'>" . $error_msg . "</font></strong></td></tr>"; } } echo "</table>"; } } $this->view->formData = $formData; $this->view->formErrors = $formErrors; exit; }