Пример #1
0
    function actionAddVariation() {
        if (isset($_GET['product_id']) && $_GET['product_id']) {
            $variation = new Variation();
            $variation->save();

            $variation_id = $variation->getPrimaryKey();

            $product2variation = new Product2variation();
            $product2variation->product_id = $_GET['product_id'];
            $product2variation->variation_id = $variation_id;
            $product2variation->save();

            $allLangs = LanguageModel::model()->findAll('1', array('order'=> 'id ASC'));
            foreach ($allLangs as $language) {
                $variation_description = new VariationDescription();
                $variation_description->variation_id = $variation_id;
                $variation_description->language_id = $language['id'];
                $variation_description->save();
            }
            $this->actionUpdate($_GET['product_id']);
            die();
        }
    }
Пример #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');
     }
 }