public function actionDialogBillSendProduct($bill_type = "send")
 {
     // organization data
     $org = Organization::model()->find();
     // bill_sale data
     $billSale = BillSale::model()->find(array('limit' => 1, 'order' => 'bill_sale_id DESC'));
     // bill_sale_detail data
     $billSaleDetail = BillSaleDetail::model()->findAll(array('condition' => "bill_id = {$billSale->bill_sale_id}"));
     // member
     if ($billSale->member_id > 0) {
         $criteria = new CDbCriteria();
         $criteria->compare('member_code', @$billSale->member->member_code);
         $member = Member::model()->find($criteria);
     } else {
         $member = null;
     }
     $this->renderPartial('//Report/BillSendProduct', array('org' => $org, 'billSale' => $billSale, 'billSaleDetail' => $billSaleDetail, 'member' => $member, 'billType' => $bill_type));
 }
Exemplo n.º 2
0
"
                                           style="text-align: right; width: 150px" />
                                </div>

                                <!-- end form -->
                            </form>
                        </div>
                    </div>
                </div>

                <!-- รายการขายล่าสุด -->
                <?php 
$user_id = Yii::app()->request->cookies['user_id']->value;
$lastBillSale = BillSale::model()->find(array('limit' => 1, 'order' => 'bill_sale_id DESC', 'condition' => 'user_id = :user_id', 'params' => array('user_id' => $user_id)));
if (!empty($lastBillSale)) {
    $lastBillSaleDetails = BillSaleDetail::model()->findAllByAttributes(array('bill_id' => $lastBillSale->bill_sale_id));
}
?>
                <?php 
if (!empty($lastBillSale)) {
    ?>
                    <div class="panel panel-primary" style="margin-top: 15px">
                        <div class="panel-heading">
                            <div class="pull-left">
                                <i class="glyphicon glyphicon-ok"></i>
                                <?php 
    echo Yii::t('lang', 'recent_sales');
    ?>
                            </div>
                            <div class="pull-right">
                                <i class="glyphicon glyphicon-cog"></i>
$billConfig = BillConfig::model()->find();
// style
$style = "\n\t<style>\n\t\t.text {\n\t\t\tfont-size: 13px;\n\t\t}\n\t\t.bold {\n\t\t\tfont-weight: bold;\n\t\t}\n\t\t.red {\n\t\t\tfont-color: #FF0000;\n\t\t}\n\t\t.cell {\n\t\t\tpadding: 5px;\n\t\t\tfont-size: 13px;\n";
if ($billConfig->bill_add_show_line == 'yes') {
    $style .= "border-bottom: #cccccc 1px solid;";
}
$style .= "\n\t\t}\n\t\t.cell-header {\n\t\t\ttext-align: center;\n\t\t\tbackground: #cccccc;\n\t\t}\n\t\t.right {\n\t\t\ttext-align: right;\n\t\t}\n\t\t.center {\n\t\t\ttext-align: center;\n\t\t}\n\t\t.cell-footer {\n\t\t\tfont-size: 13px;\n\t\t}\n\t</style>\n";
// header text
$header_text = "\n\t<div>\n\t\t<div class='center bold'>\n\t\t\tใบกำกับภาษี\n\t\t</div>\n\t</div>\n\t<div>\n\t\t<span class='text'>\n\t\t\tเลขที่: <span class='bold'>{$billSale->bill_sale_id}</span>\n\t\t\tวันที่: <span class='bold red'>{$nowThai}</span>\n\t\t</span>\n\t</div>\n\t<div>\n\t\t<span class='text'>\n\t\t\tร้าน: \n\t\t\t<span class='bold red'>{$org->org_name}</span>\n\t\t</span>\n\t\t<span class='text'>\n\t\t\tสาขา:\n\t\t\t<span class='bold red'>{$billSale->branch->branch_name}</span>\n\t\t</span>\n\t</div>\n\t<div>\n\t\t<span class='text'>\n\t\t\t<div>{$org->org_address_1}</div>\n\t\t\t<div>{$org->org_address_2}</div>\n\t\t\t<div>{$org->org_address_3}</div>\n\t\t\t<div>{$org->org_address_4}</div>\n\t\t\t<div>\n\t\t\t\t<span style='padding-right: 40px'>\n\t\t\t\t\tเลขประจำตัวผู้เสียภาษี: {$org->org_tax_code}\n\t\t\t\t</span>\n\t\t\t\t\n\t\t\t\t<span style='padding-right: 40px'>\n\t\t\t\t\tโทรศัพท์: {$org->org_tel}\t\t\t\t\n\t\t\t\t</span>\n\t\t\t\t\n\t\t\t\t<span>\n\t\t\t\t\tแฟกซ์: {$org->org_fax}\n\t\t\t\t</span>\n\t\t\t</div>\t\n\t\t</span>\n\t</div>\n\t<div>\n\t\t<span class='text'>\n\t\t\t<div class=''>\n\t\t\t\t<strong>ลูกค้า</strong>\n\t\t\t\t<span>\n\t\t\t\t\t{$billSale->member->member_code} \n\t\t\t\t\t{$billSale->member->member_name}\n\t\t\t\t</span>\n\n\t\t\t\t<strong>เบอร์โทร: </strong>\n\t\t\t\t<span>{$billSale->member->member_tel}</span>\n\n\t\t\t\t<strong>เลขประจำตัวผู้เสียภาษี: </strong>\n\t\t\t\t<span>{$billSale->member->tax_code}</span>\n\t\t\t</div>\n\t\t\t<div>{$billSale->member->member_address}</div>\n\t\t</span>\n\t</div>\n";
// body
$body_text = "\n\t<table width='100%'>\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<td class='cell cell-header' width='40px'>ลำดับ</td>\n\t\t\t\t<td class='cell cell-header' width='100px'>รหัสสินค้า</td>\n\t\t\t\t<td class='cell cell-header'>ชื่อ</td>\n\t\t\t\t<td class='cell cell-header' width='50px'>จำนวน</td>\n\t\t\t\t<td class='cell cell-header' width='110px'>ราคาต่อหน่วย</td>\n\t\t\t\t<td class='cell cell-header' width='70px'>ราคารวม</td>\n\t\t\t</tr>\n\t\t</thead>\n";
$n = 1;
$sumPrice = 0;
$criteria = new CDbCriteria();
$criteria->compare('bill_id', $billSale->bill_sale_id);
$billSaleDetails = BillSaleDetail::model()->findAll($criteria);
foreach ($billSaleDetails as $billSaleDetail) {
    $qty = $billSaleDetail->bill_sale_detail_qty;
    $price = $billSaleDetail->bill_sale_detail_price;
    $totalPricePerRow = $qty * $price;
    $sumPrice += $totalPricePerRow;
    $totalPricePerRowOutput = number_format($totalPricePerRow);
    $product_name = $billSaleDetail->product->product_name;
    $product_code = $billSaleDetail->bill_sale_detail_barcode;
    // find name of product
    if (empty($product_name)) {
        $productPrice = BarcodePrice::model()->findByPk($product_code);
        $fk = $productPrice->barcode_fk;
        $productRelate = Product::model()->findByAttributes(array('product_code' => $fk));
        $product_name = $productRelate->product_name . " ({$productPrice->name})";
    }
Exemplo n.º 4
0
 public function actionSendFromQuotationBillToBillSale()
 {
     $this->checkLogin();
     $quotation_id = (int) $_POST['quotation_id'];
     $vat_price = $_POST['vat_price'];
     $quotation = Quotation::model()->findByPk((int) $quotation_id);
     if (!empty($quotation)) {
         $billSale = BillSale::model()->findByAttributes(array('quotation_id' => $quotation_id));
         if (empty($billSale)) {
             $user_id = Yii::app()->request->cookies['user_id']->value;
             $user = User::model()->findByPk($user_id);
             //
             // create bill_sale
             //
             $billSale = new BillSale();
             $billSale->quotation_id = $quotation_id;
             $billSale->sale_type = 'sale';
             $billSale->bill_sale_pay_date = new CDbExpression('NOW()');
             $billSale->branch_id = $user->branch_id;
             $billSale->user_id = $user_id;
             $billSale->member_id = 0;
             $billSale->bill_sale_status = 'pay';
             $billSale->bill_sale_created_date = new CDbExpression('NOW()');
             if ($quotation->vat > 0) {
                 $vat_price = str_replace(',', '', $vat_price);
                 $billSale->vat_type = 'out';
                 $billSale->out_vat = $vat_price;
                 $billSale->bill_sale_vat = 'vat';
                 $billSale->vat_percen = $quotation->vat;
             }
             if ($billSale->save()) {
                 //
                 // read from quotation and transfer to tb_bill_sale_detail
                 //
                 $quotationDetails = QuotationDetail::model()->findAllByAttributes(array('quotation_id' => $quotation_id));
                 foreach ($quotationDetails as $quotationDetail) {
                     $billSaleDetail = new BillSaleDetail();
                     $billSaleDetail->bill_id = $billSale->bill_sale_id;
                     $billSaleDetail->bill_sale_detail_barcode = $quotationDetail->barcode;
                     $billSaleDetail->bill_sale_detail_price = $quotationDetail->old_price;
                     $billSaleDetail->bill_sale_detail_qty = $quotationDetail->qty;
                     $billSaleDetail->sub = $quotationDetail->sub;
                     $billSaleDetail->quotation_detail_id = $quotationDetail->id;
                     $billSaleDetail->save();
                 }
                 echo $billSale->bill_sale_id;
             }
         } else {
             echo $billSale->bill_sale_id;
         }
     }
 }
Exemplo n.º 5
0
 public function actionEndSaleMobile()
 {
     $user_id = (int) Yii::app()->request->cookies['user_id']->value;
     $user = User::model()->findByPk($user_id);
     $saleTemps = SaleTemp::model()->findAllByAttributes(array('user_id' => $user_id, 'sale_type' => 'mobile'));
     // find total money
     $total_money = 0;
     foreach ($saleTemps as $saleTemp) {
         $total_money += $saleTemp->price;
     }
     // bill sale
     $billSale = new BillSale();
     $billSale->bill_sale_created_date = new CDbExpression('NOW()');
     $billSale->bill_sale_status = 'pay';
     $billSale->member_id = 0;
     $billSale->bill_sale_vat = 'no';
     $billSale->user_id = $user_id;
     $billSale->branch_id = $user->branch_id;
     $billSale->bill_sale_pay_date = new CDbExpression('NOW()');
     $billSale->vat_type = 'in';
     $billSale->bonus_price = 0;
     $billSale->out_vat = 0;
     $billSale->input_money = 0;
     $billSale->return_money = 0;
     $billSale->total_money = $total_money;
     $billSale->sale_type = 'mobile';
     if ($billSale->save()) {
         // bill sale detail
         foreach ($saleTemps as $saleTemp) {
             $info = Product::getInfoByBarcode($saleTemp->barcode);
             $billSaleDetail = new BillSaleDetail();
             $billSaleDetail->bill_id = $billSale->bill_sale_id;
             $billSaleDetail->bill_sale_detail_barcode = $saleTemp->barcode;
             $billSaleDetail->bill_sale_detail_price = $saleTemp->price;
             $billSaleDetail->bill_sale_detail_price_vat = 0;
             $billSaleDetail->bill_sale_detail_qty = 1;
             $billSaleDetail->bill_sale_detail_has_bonus = 'no';
             $billSaleDetail->bill_sale_detail_type = 'one';
             $billSaleDetail->old_price = $info['old_price'];
             $billSaleDetail->save();
         }
         // clear sale temp
         SaleTemp::model()->deleteAllByAttributes(array('user_id' => $user_id, 'sale_type' => 'mobile'));
         // success
         echo 'success';
     }
 }
 public function actionClearBillSale()
 {
     $this->checkLogin();
     BillSale::model()->deleteAll();
     BillSaleDetail::model()->deleteAll();
     $this->redirect(array("Basic/ManageBill"));
 }
Exemplo n.º 7
0
 public function actionArDetail($bill_sale_id)
 {
     $billSaleDetails = BillSaleDetail::model()->findAll(array('condition' => "bill_id = :bill_sale_id", 'order' => 'bill_sale_detail_id DESC', 'params' => array('bill_sale_id' => (int) Util::input($bill_sale_id))));
     $this->renderPartial('//Report/ArDetail', array('billSaleDetails' => $billSaleDetails, 'n' => 1, 'bill_sale_id' => $bill_sale_id, 'sum' => 0));
 }