當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Facture::insert_discount方法代碼示例

本文整理匯總了PHP中Facture::insert_discount方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::insert_discount方法的具體用法?PHP Facture::insert_discount怎麽用?PHP Facture::insert_discount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Facture的用法示例。


在下文中一共展示了Facture::insert_discount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: count

 $num = count($lines);
 for ($i = 0; $i < $num; $i++) {
     $desc = $lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle;
     if ($lines[$i]->subprice < 0) {
         // Negative line, we create a discount line
         $discount = new DiscountAbsolute($db);
         $discount->fk_soc = $object->socid;
         $discount->amount_ht = abs($lines[$i]->total_ht);
         $discount->amount_tva = abs($lines[$i]->total_tva);
         $discount->amount_ttc = abs($lines[$i]->total_ttc);
         $discount->tva_tx = $lines[$i]->tva_tx;
         $discount->fk_user = $user->id;
         $discount->description = $desc;
         $discountid = $discount->create($user);
         if ($discountid > 0) {
             $result = $object->insert_discount($discountid);
             //$result=$discount->link_to_invoice($lineid,$id);
         } else {
             setEventMessages($discount->error, $discount->errors, 'errors');
             $error++;
             break;
         }
     } else {
         // Positive line
         $product_type = $lines[$i]->product_type ? $lines[$i]->product_type : 0;
         // Date start
         $date_start = false;
         if ($lines[$i]->date_debut_prevue) {
             $date_start = $lines[$i]->date_debut_prevue;
         }
         if ($lines[$i]->date_debut_reel) {
開發者ID:NoisyBoy86,項目名稱:Dolibarr_test,代碼行數:31,代碼來源:orderstoinvoice.php

示例2: CreateFacture


//.........這裏部分代碼省略.........
         $object = new Facturesim($db);
     } else {
         $object = new Facture($db);
     }
     $object->type = $data['type'] == 0 ? 0 : 2;
     $object->socid = $socid;
     $object->statut = $data['state'];
     $object->fk_cash = $terminal;
     $object->remise_percent = $data['discount_percent'];
     $object->remise_absolue = $data['discount_qty'];
     if ($data['customerpay1'] > 0) {
         $object->mode_reglement_id = $cash->fk_modepaycash;
     } else {
         if ($data['customerpay2'] > 0) {
             $object->mode_reglement_id = $cash->fk_modepaybank;
         } else {
             $object->mode_reglement_id = $cash->fk_modepaybank_extra;
         }
     }
     $object->fk_place = $data['id_place'];
     $object->note_private = $data['note'];
     $object->customer_pay = $data['customerpay'];
     if ($object->customer_pay > 0) {
         $object->diff_payment = $data['difpayment'];
     } else {
         $object->diff_payment = $data['total'];
     }
     $object->fk_facture_source = $data['idsource'];
     $employ = new User($db);
     $employ->fetch($employee);
     $employ->getrights();
     $now = dol_now();
     $object->date = $now;
     $db->begin;
     $idFacture = $object->create($employ);
     if ($object->statut == 1 || $object->type == 2) {
         $res = $object->validate($employ);
         if ($res < 0) {
             $soc = new Societe($db);
             $soc->fetch($socid);
             $num = $object->getNextNumRef($soc);
             // Validate
             $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture';
             $sql .= " SET facnumber='" . $num . "', fk_statut = 1, fk_user_valid = " . $employ->id . ", date_valid = '" . $db->idate($now) . "'";
             if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
                 $sql .= ', datef=' . $db->idate($now);
                 $sql .= ', date_lim_reglement=' . $db->idate($now);
             }
             $sql .= ' WHERE rowid = ' . $object->id;
             dol_syslog(get_class($this) . "::validate sql=" . $sql);
             $resql = $db->query($sql);
             $object->ref = $num;
         }
     }
     $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'pos_facture (fk_cash, fk_place,fk_facture,customer_pay) VALUES (' . $object->fk_cash . ',' . ($object->fk_place ? $object->fk_place : 'null') . ',' . $idFacture . ',' . $object->customer_pay . ')';
     dol_syslog("pos_facture::update sql=" . $sql);
     $resql = $db->query($sql);
     if (!$resql) {
         $this->db->rollback();
         return -1;
     }
     $data['ref'] = $object->ref;
     if ($idFacture < 0) {
         $db->rollback();
         return -1;
     } else {
         //Adding lines
         $data['id'] = $idFacture;
         //introducir descuentos
         if (!empty($data['idCoupon'])) {
             $res_dis = $object->insert_discount($data['idCoupon']);
         } else {
             $res_dis = 1;
         }
         $idLines = self::addFactureLines($lines, $idFacture, $object->type == 1 ? true : false);
         if ($idLines < 0 || $res_dis < 0) {
             $db->rollback();
             return -2;
         } else {
             //Adding Payments
             $payment = self::addPaymentFac($data);
             if ($payment < 0) {
                 $db->rollback();
                 return -3;
             }
             //Decrease stock
             $stock = self::quitSotck($lines, $object->type == 2 ? true : false);
             if ($stock) {
                 $db->rollback();
                 return -4;
             }
         }
     }
     if ($idTicket) {
         $ticket = new Ticket($db);
         $ticket->fetch($idTicket);
         $ticket->delete_ticket();
     }
     return $idFacture;
 }
開發者ID:LionSystemsSolutions,項目名稱:El-Canelo-ERP,代碼行數:101,代碼來源:pos.class.mañanero.php

示例3: createFactureFromObject

 static function createFactureFromObject(&$object)
 {
     global $db, $conf, $user, $langs;
     dol_include_once('/compta/facture/class/facture.class.php');
     $langs->load('grapefruit@grapefruit');
     $dateinvoice = dol_mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     $f = new Facture($db);
     $f->socid = $object->socid;
     $f->type = Facture::TYPE_STANDARD;
     $f->number = $_POST['facnumber'];
     $f->date = $dateinvoice;
     $f->note_public = $object->note_public;
     $f->note_private = $object->note_private;
     $f->ref_client = $object->ref_client;
     $f->fk_project = $object->fk_project;
     $f->cond_reglement_id = $object->cond_reglement_id;
     $f->mode_reglement_id = $object->mode_reglement_id;
     $origin = 'commande';
     $originid = $object->id;
     $f->linked_objects[$origin] = $originid;
     $id = $f->create($user);
     $lines = $object->lines;
     if (empty($lines) && method_exists($object, 'fetch_lines')) {
         $object->fetch_lines();
         $lines = $object->lines;
     }
     $fk_parent_line = 0;
     $num = count($lines);
     for ($i = 0; $i < $num; $i++) {
         $label = !empty($lines[$i]->label) ? $lines[$i]->label : '';
         $desc = !empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle;
         if ($f->situation_counter == 1) {
             $lines[$i]->situation_percent = 0;
         }
         if ($lines[$i]->subprice < 0) {
             // Negative line, we create a discount line
             $discount = new DiscountAbsolute($db);
             $discount->fk_soc = $f->socid;
             $discount->amount_ht = abs($lines[$i]->total_ht);
             $discount->amount_tva = abs($lines[$i]->total_tva);
             $discount->amount_ttc = abs($lines[$i]->total_ttc);
             $discount->tva_tx = $lines[$i]->tva_tx;
             $discount->fk_user = $user->id;
             $discount->description = $desc;
             $discountid = $discount->create($user);
             if ($discountid > 0) {
                 $result = $f->insert_discount($discountid);
                 // This include link_to_invoice
             } else {
                 setEventMessages($discount->error, $discount->errors, 'errors');
                 $error++;
                 break;
             }
         } else {
             // Positive line
             $product_type = $lines[$i]->product_type ? $lines[$i]->product_type : 0;
             // Date start
             $date_start = false;
             if ($lines[$i]->date_debut_prevue) {
                 $date_start = $lines[$i]->date_debut_prevue;
             }
             if ($lines[$i]->date_debut_reel) {
                 $date_start = $lines[$i]->date_debut_reel;
             }
             if ($lines[$i]->date_start) {
                 $date_start = $lines[$i]->date_start;
             }
             // Date end
             $date_end = false;
             if ($lines[$i]->date_fin_prevue) {
                 $date_end = $lines[$i]->date_fin_prevue;
             }
             if ($lines[$i]->date_fin_reel) {
                 $date_end = $lines[$i]->date_fin_reel;
             }
             if ($lines[$i]->date_end) {
                 $date_end = $lines[$i]->date_end;
             }
             // Reset fk_parent_line for no child products and special product
             if ($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line) || $lines[$i]->product_type == 9) {
                 $fk_parent_line = 0;
             }
             // Extrafields
             if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) {
                 $lines[$i]->fetch_optionals($lines[$i]->rowid);
                 $array_options = $lines[$i]->array_options;
             }
             // View third's localtaxes for now
             $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $f->client);
             $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $f->client);
             $result = $f->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $f->origin, $lines[$i]->rowid, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit);
             if ($result > 0) {
                 $lineid = $result;
             } else {
                 $lineid = 0;
                 $error++;
                 break;
             }
             // Defined the new fk_parent_line
             if ($result > 0 && $lines[$i]->product_type == 9) {
//.........這裏部分代碼省略.........
開發者ID:ATM-Consulting,項目名稱:dolibarr_module_grapefruit,代碼行數:101,代碼來源:grapefruit.class.php


注:本文中的Facture::insert_discount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。