Ejemplo n.º 1
0
    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>&nbsp;</td>
				<td>&nbsp;</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>&nbsp;";
                    ?>
<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;
    }
Ejemplo n.º 2
0
    public function addsubscriptionAction()
    {
        $this->view->messages = $this->_flashMessenger->getMessages();
        $this->_helper->layout->disableLayout();
        $modelPrice = new Publisher_Model_DbTable_Subscriptions();
        $formData = array();
        $formErrors = array();
        $formData = $_POST;
        if ($this->getRequest()->isPost() && (!empty($formData['createsubscription']) && $formData['createsubscription'] == 'Add Subscription')) {
            $check_data = $modelPrice->fetchAll('country_sub="' . $formData['country_sub'] . '" and language_sub="' . $formData['language'] . '" and subscription_type="' . $formData['subscription_type'] . '" and product_id="' . $formData['productid'] . '"');
            if (!isset($formData['country_sub']) || trim($formData['country_sub']) == "") {
                $formErrors['country_sub'] = "Please select country ";
            }
            if (!isset($formData['language']) || trim($formData['language']) == "") {
                $formErrors['language'] = "Please select language";
            }
            if (!isset($formData['individual_price']) || trim($formData['individual_price']) == "") {
                $formErrors['individual_price'] = "Please select price";
            }
            if (count($check_data) > 0) {
                $formErrors['subscription_type'] = "Subscription could not be saved. This subscription already exists";
            }
            if (count($formErrors) == 0) {
                $priceId = 0;
                $price_error = array();
                if ($formData['group_price_sub'] == '') {
                    $group_price = $formData['individual_price'];
                } else {
                    $group_price = $formData['group_price_sub'];
                }
                $priceData = array('product_id' => $formData['productid'], 'country_sub' => $formData['country_sub'], 'language_sub' => $formData['language'], 'subscription_type' => $formData['subscription_type'], 'number_of_issues' => $formData['number_of_issues'], 'individual_price' => $formData['individual_price'], 'group_price_sub' => $group_price);
                $priceId = $modelPrice->insert($priceData);
                //print_r($priceData);
                //echo ">>>".$priceId;
                //die();
            }
            if (empty($priceId)) {
                $price_error[] = "";
            }
            //$createsubscriptionURL = "http://miprojects2.com.php53-6.ord1-1.websitetestlink.com/projects/evendor/publisher/book/addsubscription/";
            $createsubscriptionURL = $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'addsubscription'), '', true);
            ?>
		<form name="form-add-subscription" id="form-add-subscription " method="post" onsubmit="return  validate_subscription_form('form-add-subscription','<?php 
            echo $createsubscriptionURL;
            ?>
');">
		  <fieldset class="dashboard_fieldset">
				<legend>Publication Subscription</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_sub" id="country_sub" class="req" onchange="getCurrency(this.value);"  message="Please select country for subscription">
					<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>';
            }
            ?>
					<br/>
					<span id="err_country" style="color:#f00;"></span>
					</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>';
            }
            ?>
					<br/>
					<span id="err_language" style="color:#f00;"></span>
					</td>
					</tr>
					
					<tr>
				<td class="tdleftBold">Select Subscription<span class="required">*</span> : </td>
				<td><span id="currency_singh"></span>
				<select name="subscription_type" id="subscription_type"  class="req"  message="Please select subscription type">
				<option value="">Select</option>
				<option value="Weekly">Weekly</option>
				<option value="Monthly">Monthly</option>
				<option value="Quarterly">Quarterly</option>
				<option value="Half Yearly">Half Yearly</option>
				<option value="Yearly">Yearly</option>
				</select>
				<br/>
				<span id="err_subscription" style="color:#f00;"></span>
				</td>
				</tr>
			
				<tr>
				<td class="tdleftBold">Number of issues<span class="required">*</span> : </td>
				<td><span id="currency_singh"></span>
				<input type="text" name="number_of_issues" id="number_of_issues"  class="req number"  message="Please enter number of issues" invalidmessage="Please enter numeric value for number of issues" />
				<?php 
            if (array_key_exists('number_of_issues', $formErrors)) {
                echo '<div class="inline-error">' . $formErrors['number_of_issues'] . '</div>';
            }
            ?>
				<br/>
				<span id="err_numberofissues" style="color:#f00;"></span>
				</td>
				</tr>
			
			
			
					<tr>
					<td class="tdleftBold">Individual Price<span class="required">*</span> : </td>
					<td><span id="currency_singh"></span>
					<input type="text" name="individual_price" id="individual_price"  class="req number"  message="Please enter price"/>
					<?php 
            if (array_key_exists('individual_price', $formErrors)) {
                echo '<div class="inline-error">' . $formErrors['individual_price'] . '</div>';
            }
            ?>
					<br/>
					<span id="err_individualprice" style="color:#f00;"></span>
					</td>
					</tr>
					
					<tr>
					<td class="tdleftBold">Group Price : </td>
					<td><span id="currency_singh"></span>
					<input type="text" name="group_price_sub" id="group_price_sub" />
					<?php 
            if (array_key_exists('group_price_sub', $formErrors)) {
                echo '<div class="inline-error">' . $formErrors['group_price_sub'] . '</div>';
            }
            ?>
					</td>
					</tr>
					<tr>
					<td>&nbsp;</td>
					<td align="center"><input type="checkbox" name="chk_terms" id="chk_terms" value="1" class="req" message="Please check if you agree terms and conditions"/>I agree to <a href="terms_conditions.php">Terms and conditions</a>
					<br/>
					<span id="err_chkterms" style="color:#f00;"></span>
				</td>
				</tr> 
			
					<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="2">
							<div style="text-align:center;">
								<input type="hidden" name="createsubscription" value="Add Subscription">
								<input type="hidden" name="productid" id="productid" value="<?php 
            echo $_REQUEST['productid'];
            ?>
" />
								<input type="submit" name="createsubscription" id="createsubscription" value="Add Subscription" class="button-Save"/>
							</div>
							
						</td>
					</tr>

					</table>
			</fieldset>
			</form>

		<?php 
            echo "77777777777<fieldset class='dashboard_fieldset'>\n\t\t\t\t<legend>Store Price</legend><table width='100%' class='table-list' border='0' cellspacing='0' cellpadding='0'><tr>\n\t\t<td width='50%'><div align='left'><strong>Store</strong></div></td>\n\t\t<td width='30%'><div align='left'><strong>Language</strong></div></td>\n\t\t<td width='10%'><div align='left'><strong>Subscription type</strong></div></td>\n\t\t<td width='10%'><div align='left'><strong>Number of issues</strong></div></td>\n\t\t<td width='10%'><div align='left'><strong>Price</strong></div></td>\n\t\t<td width='20%'><div align='left'><strong>Group Price</strong></div></td>\n\t\t<td width='10%'><div align='left'><strong>Action</strong></div></td>\n\t\t</tr>";
            $modelSubscription = new Publisher_Model_DbTable_Subscriptions();
            $subscriptionList = $modelSubscription->getSubscriptionList($formData['productid']);
            for ($jj = 0; $jj < count($subscriptionList); $jj++) {
                $deletePriceUrl = $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'deletesubscription', 'id' => $subscriptionList[$jj]['id']), '', true);
                echo "<tr><td><div align='left'>";
                $modelCountry = new Publisher_Model_DbTable_Books();
                $producturrency = new Admin_Model_DbTable_Countries();
                $countryRecord = $modelCountry->getCountryName($subscriptionList[$jj]['country_sub']);
                echo $countryRecord['country'];
                echo "</div></td><td><div align='left'>";
                $modelLanguage = new Publisher_Model_DbTable_Books();
                $languageRecord = $modelLanguage->getLanguageName($subscriptionList[$jj]['language_sub']);
                echo $languageRecord['language_name'];
                echo "</div></td><td><div align='left'>";
                echo $subscriptionList[$jj]['subscription_type'];
                echo "</div></td><td><div align='left'>";
                echo $subscriptionList[$jj]['number_of_issues'];
                echo "</div></td><td><div align='left'>";
                echo $producturrency->getCurrencyInfo($subscriptionList[$jj]['country_sub']) . "" . $subscriptionList[$jj]['individual_price'];
                echo "</div></td><td><div align='left'>";
                echo $producturrency->getCurrencyInfo($subscriptionList[$jj]['country_sub']) . $subscriptionList[$jj]['group_price_sub'];
                echo "</div></td><td><div align='left'>";
                /*echo "<a class='action-icon' href='".$deletePriceUrl."' onclick='return deletesubscription(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>&nbsp;";*/
                ?>
		
		<?php 
                if ($subscriptionList[$jj]['status'] == '1') {
                    ?>
		<a class="action-icon" href="<?php 
                    echo $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'inactivesubscription', 'id' => $subscriptionList[$jj]['id']), '', true);
                    ?>
" title="Deactivate Subscription" onclick="return inactivesubscription(this.href,'tab2','book');"><img alt="Active" src="<?php 
                    echo $this->view->serverUrl() . $this->view->baseUrl();
                    ?>
/public/css/admin/images/active.png"/></a>	
		<?php 
                } else {
                    ?>
		<a class="action-icon" href="<?php 
                    echo $this->view->url(array('module' => 'publisher', 'controller' => 'book', 'action' => 'activesubscription', 'id' => $subscriptionList[$jj]['id']), '', true);
                    ?>
" title="Activate Subscription" onclick="return activesubscription(this.href,'tab2','book');"><img alt="Inactive" src="<?php 
                    echo $this->view->serverUrl() . $this->view->baseUrl();
                    ?>
/public/css/admin/images/inactive.png"/></a>
		<?php 
                }
                ?>
		
		<a href="javascript:void(0);" onclick="return updatesubscription1('<?php 
                echo $subscriptionList[$jj]['id'];
                ?>
','<?php 
                echo $this->view->serverUrl() . $this->view->baseUrl() . "/publisher/book/savesubscription";
                ?>
','<?php 
                echo $formData['productid'];
                ?>
','<?php 
                echo $subscriptionList[$jj]['id'];
                ?>
','<?php 
                echo $this->view->serverUrl() . $this->view->baseUrl() . "/publisher/book/savesubscription";
                ?>
','<?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 (count($subscriptionList) == 0) {
                echo "<tr><td colspan='6' align='center'>No Record Found</td></tr>";
            }
            if (!empty($price_error)) {
                foreach ($price_error as $error_msg) {
                    echo "<tr><td colspan='6'><strong><font color='red'>" . $error_msg . "</font></strong></td></tr>";
                }
            }
            if (!empty($formErrors)) {
                foreach ($formErrors as $error_msg) {
                    echo "<tr><td colspan='6'><strong><font color='red'>" . $error_msg . "</font></strong></td></tr>";
                }
            }
            echo "</table></fieldset>";
        }
        $this->view->formData = $formData;
        $this->view->formErrors = $formErrors;
        exit;
    }