public function deletepriceAction()
 {
     $id = $this->_request->getParam('id', 0);
     $parent_publication_id = $this->_request->getParam('parentid', 0);
     $modelPrice = new Publisher_Model_DbTable_BookPrices();
     $currentrecord = $modelPrice->CurrentRow($id);
     if ($id > 0 && $modelPrice->isExist($id)) {
         $success = $modelPrice->delete('id=' . $id);
         if ($success) {
             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='10%'><div align='left'><strong>Action</strong></div></td>\n</tr>";
             $modelPrice = new Publisher_Model_DbTable_BookPrices();
             $priceList = $modelPrice->getPriceList($currentrecord['product_id']);
             for ($jj = 0; $jj < count($priceList); $jj++) {
                 $deletePriceUrl = $this->view->url(array('module' => 'publisher', 'controller' => 'issues', 'action' => 'deleteprice', 'id' => $priceList[$jj]['id'], 'parentid' => $parent_publication_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 "<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;";
                 echo "</div></td></tr>";
             }
             echo "</table>";
             exit;
         } else {
             echo "<font color='red'><strong>Sorry!, unable to delete price</strong></font>";
             exit;
         }
     }
 }
    public function deletepriceAction()
    {
        $id = $this->_request->getParam('id', 0);
        $modelPrice = new Publisher_Model_DbTable_BookPrices();
        $currentrecord = $modelPrice->CurrentRow($id);
        if ($id > 0 && $modelPrice->isExist($id)) {
            $success = $modelPrice->delete('id=' . $id);
            if ($success) {
                echo "<table width='100%' class='table-list' border='0' cellspacing='0' cellpadding='0'><tr>\n<td width='20%'><div align='left'><strong>Country</strong></div></td>\n<td width='20%'><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($currentrecord['product_id']);
                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 $currentrecord['product_id'];
                    ?>
');"'<?php 
                    echo $priceList[$jj]['id'];
                    ?>
','<?php 
                    echo $this->view->serverUrl() . $this->view->baseUrl() . "/publisher/book/saveprice";
                    ?>
','<?php 
                    echo $formData['id'];
                    ?>
');">
<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>";
                }
                echo "</table>";
                exit;
            } else {
                echo "<font color='red'><strong>Sorry!, unable to delete price</strong></font>";
                exit;
            }
        }
    }
Esempio n. 3
0
    public function exportusercsvAction()
    {
        $bookname = $this->_request->getParam('searchword');
        $booktype = $this->_request->getParam('booktype');
        $isbnnumber = $this->_request->getParam('searchisbn');
        if (isset($bookname) && (trim($bookname) != "" || trim($booktype) != "" || trim($isbnnumber) != "")) {
            $bookname = trim($bookname);
            $booktype = trim($booktype);
            $isbnnumber = trim($isbnnumber);
            $getBrandIds = $this->modelBrand->getBrandIds($bookname);
            $whrcls = "";
            if ($bookname != "") {
                $whrcls .= " title LIKE '%" . $bookname . "%'";
                if (!empty($getBrandIds)) {
                    $whrcls .= " OR title in(" . $getBrandIds . ")";
                }
            }
            if ($booktype != "") {
                if ($bookname != "") {
                    $whrcls .= " AND product_type LIKE '%" . $booktype . "%'";
                } else {
                    $whrcls .= " product_type LIKE '%" . $booktype . "%'";
                }
            }
            if (!empty($isbnnumber)) {
                if ($bookname != "") {
                    $whrcls .= " AND isbn_number LIKE '%" . $isbnnumber . "%'";
                } elseif ($booktype != "") {
                    $whrcls .= " AND isbn_number LIKE '%" . $isbnnumber . "%'";
                } else {
                    $whrcls .= " isbn_number LIKE '%" . $isbnnumber . "%'";
                }
            }
            // $prodList=$this->modelPublications->getListWhere($whrcls);
            $sql = "select id,title,product_type,parent_brand_id,author_id,publish_time,publisher,publisher_id,admin_approve,isbn_number,is_featured from pclive_products  where {$whrcls} order by id desc";
            //$request_list=$this->modelconnections->fetchAll("intro_id='".$_SESSION['Zend_Auth']['storage']->user_id."' and conn_linkedin_id!=''");
            $request_list = $this->modelPublications->getAdapter()->fetchAll($sql);
        } else {
            //$prodList=$this->modelPublications->getList();
            $sql = "select id,title,parent_brand_id,product_type,author_id,publish_time,publisher,publisher_id,admin_approve,isbn_number,is_featured from pclive_products order by id desc";
            //$request_list=$this->modelconnections->fetchAll("intro_id='".$_SESSION['Zend_Auth']['storage']->user_id."' and conn_linkedin_id!=''");
            $request_list = $this->modelPublications->getAdapter()->fetchAll($sql);
        }
        $separator = ",";
        // separate column in csv
        $modelCategory = new Publisher_Model_DbTable_Books();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        if (count($request_list) > 0) {
            $csv_output = "";
            $csv_output .= "Title / Brand" . $separator . "Genre" . $separator . "Author / Publisher" . $separator . "ISBN / ISSN" . $separator . "Publish Time" . $separator . "Status" . $separator . "Featured\n";
            $content = '<table class="table-list" cellpadding="0" cellspacing="0" width="100%">
				<tr>
				  <th>Title / Brand</th>
				  <th>Genre</th>
				  <th>Author / Publisher</th>
				  <th>ISBN / ISSN</th>
				  <th>Publish Time</th>
				  <th>Price</th>	
				   <th>Account Number</th>
				   <th>Account Holder Name</th>
				   <th>Banker</th>
				  <th>Status</th>
				  <th>Featured</th>
				</tr>';
            foreach ($request_list as $req) {
                $productPriceInfo = array();
                $productPriceInfo = $productPrice->getPriceList($req['id']);
                $price_details = '';
                foreach ($productPriceInfo as $priceDet) {
                    $countryDet = $modelCategory->getCountryName($priceDet['country_id']);
                    if ($priceDet['price'] != '') {
                        $price_details .= $priceDet['price'] . "(P) ";
                    }
                    if ($priceDet['group_price'] != '') {
                        $price_details .= $priceDet['group_price'] . "(GP) ";
                    }
                    $price_details .= "in " . $countryDet['country'] . "<br/>";
                }
                $getBrandInfo = $modelCategory->getBrandInfo($req['title']);
                if (!empty($getBrandInfo)) {
                    $titleBrand = $getBrandInfo['brand'];
                } else {
                    $titleBrand = $req['title'];
                }
                if (!empty($req['parent_brand_id'])) {
                    $productInfo = $this->modelPublications->fetchRow('id=' . $req['parent_brand_id']);
                    $getParentBrandInfo = $modelCategory->getBrandInfo($productInfo->title);
                    if (!empty($getParentBrandInfo)) {
                        $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand;
                    }
                }
                $title = stripslashes($titleBrand);
                $genreInfo = $this->modelGenre->getGenreInfo($req['product_type']);
                $genre = $genreInfo['genre'];
                $publisher_info_array = array();
                $publisher_info_array = $this->modelPublications->getPublisherInfo($req['publisher_id']);
                $account_det = " Account No:" . $publisher_info_array['account_no'] . " Account Holder Name:" . $publisher_info_array['account_no'] . " Bank Name:" . $publisher_info_array['banker'];
                /* if(!empty($publisher_info_array))
                	   {
                	   	 $publisherName =$publisher_info_array['first_name']."&nbsp;".$publisher_info_array['last_name'];
                	   }
                	   else
                	   {
                			$publisherName = $req['publisher'];
                	   }	*/
                $publisherName = $req['publisher'];
                $isbnNumber = $req['isbn_number'];
                $pubTime = $req['publish_time'];
                if ($req['admin_approve'] == '1') {
                    $status = "Aproved";
                } else {
                    $status = "Not Aproved";
                }
                if ($req['is_featured'] == '1') {
                    $featured = "Yes";
                } else {
                    $featured = "No";
                }
                $content .= '<tr>
					 			<td>' . str_replace(",", "", $title) . '</td>
				 				<td>' . str_replace(",", "", $genre) . '</td>
				  				<td>' . stripslashes($publisherName) . '</td>
				 				<td>' . $isbnNumber . '</td>
				 				<td>' . $pubTime . '</td>
								<td>' . $price_details . '</td>
								<td>' . $publisher_info_array['account_no'] . '</td>
								<td>' . $publisher_info_array['account_holder_name'] . '</td>
								<td>' . $publisher_info_array['banker'] . '</td>
				  				<td>' . $status . '</td>
				  				<td>' . $featured . '</td>
					   		</tr>';
                $csv_output .= str_replace(",", "", $title) . $separator . str_replace(",", "", $genre) . $separator . str_replace(",", "", $publisherName) . $separator . str_replace(",", "", $isbnNumber) . $separator . str_replace(",", "", $pubTime) . $separator . str_replace(",", "", $status) . $separator . $featured . "\n";
            }
        } else {
            $content .= '<tr><td colspan="8" class="list-not-found">Data Not Found</td></tr>';
        }
        $content .= '</table>';
        $file = "publications";
        $filename = $file . "_" . time() . ".xls";
        $test = $content;
        header("Content-type: application/vnd.ms-excel");
        header("Content-Disposition: attachment; filename={$filename}");
        echo $test;
        exit;
        /*header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        		header("Content-type: application/vnd.ms-excel");
        		header("Content-type: application/vnd.ms-excel");
        		header("Content-type: application/xls");
        		//header("Content-disposition: excel".time().".csv");
        		header("Content-Disposition: attachment; filename=".$filename.".xls");
        		header( "Content-disposition: filename=".$filename.".xls");
        		print $csv_output;
        		exit;*/
    }