Esempio n. 1
0
 public function actionDelete($id)
 {
     $this->loadModel($id)->delete();
     ProductDescription::model()->deleteAll('product_id=' . $id);
     Category2product::model()->deleteAll('product_id=' . $id);
     $aVariations = Product2variation::model()->findAll('product_id=' . $id);
     foreach ($aVariations as $variation) {
         Variation::model()->deleteAll('variation_id=' . $variation['variation_id']);
         VariationDescription::model()->deleteAll('variation_id=' . $variation['variation_id']);
         Variation2attribute::model()->deleteAll('variation_id=' . $variation['variation_id']);
         Variation2value::model()->deleteAll('variation_id=' . $variation['variation_id']);
     }
     Product2variation::model()->deleteAll('product_id=' . $id);
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax']))
       $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
 }
Esempio n. 2
0
 public function actionPDF()
 {
     $session = new CHttpSession();
     $session->open();
     if (isset($session['orderVariations']) && is_array($session['orderVariations']) && count($session['orderVariations']) > 0) {
         require_once Yii::getPathOfAlias('webroot.protected.extensions.pdf.tcpdf') . DIRECTORY_SEPARATOR . 'tcpdf.php';
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
         $aOrderVariations = $session['orderVariations'];
         $html_output = '<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><table>';
         $html_output .= '<tr><td colspan="3"></td></tr>';
         $html_output .= '<tr><td colspan="3">' . Yii::t('strings', 'Order products:') . "</td></tr>";
         $html_output .= '<tr><td colspan="3"></td></tr>';
         foreach ($aOrderVariations as $variation_id) {
             $Product2variation = Product2variation::model()->find('variation_id=' . $variation_id);
             if (isset($Product2variation)) {
                 $product = ProductDescription::model()->find('product_id=' . $Product2variation['product_id'] . ' AND language_id=' . $this->language_id);
                 $Variation = Variation::model()->find('variation_id=' . $variation_id);
                 $VariationDescription = VariationDescription::model()->find('variation_id=' . $variation_id . ' AND language_id=' . $this->language_id);
                 $html_output .= '<tr><td colspan="3">' . $product['product_name'] . '</td></tr>';
                 $html_output .= '<tr><td><img src="' . Yii::app()->request->getBaseUrl(true) . '/uploads/images/' . $Variation['variation_image'] . '" alt="product_image" width="100" height="50"/></td>';
                 $html_output .= '<td>' . $VariationDescription['variation_name'] . '<br/>' . $VariationDescription['variation_description'] . "</td></tr>";
                 $html_output .= '<tr><td colspan="3"></td><td></td></tr>';
             }
         }
         $html_output .= '</table></body></html>';
         $pdf->SetHeaderData(PDF_HEADER_LOGO, '', '', '', array(0, 64, 255), array(169, 172, 182));
         $pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128));
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
         $pdf->setLanguageArray($l);
         $pdf->setFontSubsetting(true);
         $pdf->SetFont('dejavusans', '', 14, '', true);
         $pdf->AddPage();
         $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
         $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html_output, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = 'L', $autopadding = true);
         $pdf->Output('order.pdf', 'I');
     }
 }