本文整理匯總了PHP中Facture::add_object_linked方法的典型用法代碼示例。如果您正苦於以下問題:PHP Facture::add_object_linked方法的具體用法?PHP Facture::add_object_linked怎麽用?PHP Facture::add_object_linked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Facture
的用法示例。
在下文中一共展示了Facture::add_object_linked方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createFromCurrent
/**
* Create a new invoice in database from current invoice
*
* @param User $user Object user that ask creation
* @param int $invertdetail Reverse sign of amounts for lines
* @return int <0 if KO, >0 if OK
*/
function createFromCurrent($user, $invertdetail = 0)
{
global $conf;
// Charge facture source
$facture = new Facture($this->db);
$facture->fk_facture_source = $this->fk_facture_source;
$facture->type = $this->type;
$facture->socid = $this->socid;
$facture->date = $this->date;
$facture->note_public = $this->note_public;
$facture->note_private = $this->note_private;
$facture->ref_client = $this->ref_client;
$facture->modelpdf = $this->modelpdf;
$facture->fk_project = $this->fk_project;
$facture->cond_reglement_id = $this->cond_reglement_id;
$facture->mode_reglement_id = $this->mode_reglement_id;
$facture->remise_absolue = $this->remise_absolue;
$facture->remise_percent = $this->remise_percent;
$facture->origin = $this->origin;
$facture->origin_id = $this->origin_id;
$facture->lines = $this->lines;
// Tableau des lignes de factures
$facture->products = $this->lines;
// Tant que products encore utilise
$facture->situation_counter = $this->situation_counter;
$facture->situation_cycle_ref = $this->situation_cycle_ref;
$facture->situation_final = $this->situation_final;
// Loop on each line of new invoice
foreach ($facture->lines as $i => $line) {
$facture->lines[$i]->fk_prev_id = $this->lines[$i]->rowid;
if ($invertdetail) {
$facture->lines[$i]->subprice = -$facture->lines[$i]->subprice;
$facture->lines[$i]->total_ht = -$facture->lines[$i]->total_ht;
$facture->lines[$i]->total_tva = -$facture->lines[$i]->total_tva;
$facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1;
$facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2;
$facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc;
}
}
dol_syslog(get_class($this) . "::createFromCurrent invertdetail=" . $invertdetail . " socid=" . $this->socid . " nboflines=" . count($facture->lines));
$facid = $facture->create($user);
if ($facid <= 0) {
$this->error = $facture->error;
$this->errors = $facture->errors;
} elseif ($this->type == self::TYPE_SITUATION && !empty($conf->global->INVOICE_USE_SITUATION)) {
$this->fetchObjectLinked('', '', $object->id, 'facture');
foreach ($this->linkedObjectsIds as $typeObject => $Tfk_object) {
foreach ($Tfk_object as $fk_object) {
$facture->add_object_linked($typeObject, $fk_object);
}
}
$facture->add_object_linked('facture', $this->fk_facture_source);
}
return $facid;
}
示例2: Facture
//.........這裏部分代碼省略.........
// Local tax 2
$factline->subprice = $this->lines[$i]->subprice;
// P.U. HT (example 100)
$factline->remise_percent = $this->lines[$i]->remise_percent;
// % de la remise ligne (example 20%)
$factline->fk_remise_except = $this->lines[$i]->fk_remise_except;
// Link to line into llx_remise_except
$factline->rang = $this->lines[$i]->rang;
$factline->info_bits = $this->lines[$i]->info_bits;
// Liste d'options cumulables:
// Bit 0: 0 si TVA normal - 1 si TVA NPR
// Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except)
$factline->special_code = $this->lines[$i]->special_code;
// Liste d'options non cumulabels:
// 1: frais de port
// 2: ecotaxe
// 3: ??
$factline->origin = $this->lines[$i]->origin;
$factline->origin_id = $this->lines[$i]->origin_id;
//! Total HT de la ligne toute quantite et incluant la remise ligne
$factline->total_ht = $this->lines[$i]->total_ht;
//! Total TVA de la ligne toute quantite et incluant la remise ligne
$factline->total_tva = $this->lines[$i]->total_tva;
$factline->total_localtax1 = $this->lines[$i]->total_localtax1;
//Total Local tax 1 de la ligne
$factline->total_localtax2 = $this->lines[$i]->total_localtax2;
//Total Local tax 2 de la ligne
//! Total TTC de la ligne toute quantite et incluant la remise ligne
$factline->total_ttc = $this->lines[$i]->total_ttc;
$factline->fk_code_ventilation = $this->lines[$i]->fk_code_ventilation;
$factline->fk_export_compta = $this->lines[$i]->fk_export_compta;
$factline->date_start = $this->lines[$i]->date_start;
$factline->date_end = $this->lines[$i]->date_end;
// From llx_product
$factline->ref = $this->lines[$i]->ref;
// Product ref (deprecated)
$factline->product_ref = $this->lines[$i]->product_ref;
// Product ref
$factline->libelle = $this->lines[$i]->libelle;
// Product label (deprecated)
$factline->product_label = $this->lines[$i]->product_label;
// Product label
$factline->product_desc = $this->lines[$i]->product_desc;
// Description produit
$factline->skip_update_total = $this->lines[$i]->skip_update_total;
// Skip update price total for special lines
$facture->lines[$i] = $factline;
}
$facture->create($user);
if ($facture->statut == 1 || $facture->type == 1) {
$facture->validate($user);
if ($this->diff_payment <= 0) {
$facture->set_paid($user);
}
if ($this->diff_payment > 0) {
$facture->setStatut(1);
}
}
$sql = 'UPDATE ' . MAIN_DB_PREFIX . "pos_ticket SET fk_facture='" . $facture->id . "' WHERE rowid=" . $this->id;
dol_syslog("Ticket::update sql=" . $sql);
$resql = $this->db->query($sql);
if (!$resql) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'pos_facture (fk_cash, fk_place,fk_facture) VALUES (' . $this->fk_cash . ',' . ($this->fk_place ? $this->fk_place : 'null') . ',' . $facture->id . ')';
dol_syslog("pos_facture::update sql=" . $sql);
$resql = $this->db->query($sql);
if (!$resql) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
}
$sql = 'SELECT fk_paiement, amount FROM ' . MAIN_DB_PREFIX . "pos_paiement_ticket WHERE fk_ticket=" . $this->id;
$resql = $this->db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$totalpaye = 0;
while ($i < $num) {
$objp = $db->fetch_object($resql);
$paye[$i]['fk_paiement'] = $objp->fk_paiement;
$paye[$i]['amount'] = $objp->amount;
$i++;
}
$i = 0;
while ($i < $num) {
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiement_facture (fk_paiement, fk_facture, amount) VALUES (' . $paye[$i]['fk_paiement'] . ',' . $facture->id . ',' . $paye[$i]['amount'] . ')';
$resql = $this->db->query($sql);
$i++;
}
} else {
return -1;
}
$facture->add_object_linked('ticket', $this->id);
return $facture->id;
}
}