Fix problem with code of reccuring invoices
This commit is contained in:
parent
56b57b0bc9
commit
78cda5dc07
@ -341,6 +341,17 @@ class FactureRec extends CommonInvoice
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an array of invoice lines
|
||||
*
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function getLinesArray()
|
||||
{
|
||||
return $this->fetch_lines();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recupere les lignes de factures predefinies dans this->lines
|
||||
*
|
||||
@ -348,16 +359,23 @@ class FactureRec extends CommonInvoice
|
||||
*/
|
||||
function fetch_lines()
|
||||
{
|
||||
$this->lines=array();
|
||||
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
|
||||
$sql.= ' l.remise, l.remise_percent, l.subprice,';
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||
//$sql.= ' l.situation_percent, l.fk_prev_id,';
|
||||
//$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
|
||||
$sql.= ' l.rang, l.special_code,';
|
||||
//$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
|
||||
$sql.= ' l.fk_unit, l.fk_contract_line,';
|
||||
//$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
||||
|
||||
$sql.= ' ORDER BY l.rang';
|
||||
|
||||
dol_syslog('FactureRec::fetch_lines', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
@ -387,10 +405,6 @@ class FactureRec extends CommonInvoice
|
||||
$line->remise_percent = $objp->remise_percent;
|
||||
$line->fk_remise_except = $objp->fk_remise_except;
|
||||
$line->fk_product = $objp->fk_product;
|
||||
$line->date_start = $objp->date_start;
|
||||
$line->date_end = $objp->date_end;
|
||||
$line->date_start = $objp->date_start;
|
||||
$line->date_end = $objp->date_end;
|
||||
$line->info_bits = $objp->info_bits;
|
||||
$line->total_ht = $objp->total_ht;
|
||||
$line->total_tva = $objp->total_tva;
|
||||
@ -415,7 +429,7 @@ class FactureRec extends CommonInvoice
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db-lasterror();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,6 +73,13 @@ if (($id > 0 || $ref) && $action != 'create' && $action != 'add')
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('invoicecard','globalcard'));
|
||||
|
||||
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -101,7 +108,7 @@ if ($action == 'add')
|
||||
$rehour=GETPOST('rehour');
|
||||
$remin=GETPOST('remin');
|
||||
$nb_gen_max=GETPOST('nb_gen_max', 'int');
|
||||
if (empty($nb_gen_max)) $nb_gen_max =0;
|
||||
//if (empty($nb_gen_max)) $nb_gen_max =0;
|
||||
|
||||
if (GETPOST('frequency'))
|
||||
{
|
||||
@ -111,7 +118,7 @@ if ($action == 'add')
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
if ($nb_gen_max == '')
|
||||
if ($nb_gen_max === '')
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors');
|
||||
$action = "create";
|
||||
@ -599,7 +606,9 @@ if ($action == 'create')
|
||||
|
||||
if ($object->fetch($id, $ref) > 0)
|
||||
{
|
||||
print '<form action="fiche-rec.php" method="post">';
|
||||
$result = $object->getLinesArray();
|
||||
|
||||
print '<form action="fiche-rec.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="facid" value="'.$object->id.'">';
|
||||
@ -707,10 +716,22 @@ if ($action == 'create')
|
||||
|
||||
print load_fiche_titre($title, '', '');
|
||||
|
||||
|
||||
/*
|
||||
* Invoice lines
|
||||
*/
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
// Show object lines
|
||||
if (! empty($object->lines))
|
||||
{
|
||||
$disableedit=1;
|
||||
$disablemove=1;
|
||||
$disableremove=1;
|
||||
$ret = $object->printObjectLines('', $mysoc, $soc, $lineid, 0); // No date selector for template invoice
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
/*
|
||||
print '<table class="notopnoleftnoright" width="100%">';
|
||||
print '<tr><td colspan="3">';
|
||||
|
||||
@ -877,7 +898,8 @@ if ($action == 'create')
|
||||
print $db->error();
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
*/
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
if ($flag_price_may_change)
|
||||
|
||||
@ -3236,8 +3236,9 @@ abstract class CommonObject
|
||||
*/
|
||||
function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
|
||||
{
|
||||
global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $langs, $user;
|
||||
|
||||
global $conf, $hookmanager, $langs, $user;
|
||||
global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
||||
|
||||
// Define usemargins
|
||||
$usemargins=0;
|
||||
if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1;
|
||||
@ -3366,7 +3367,7 @@ abstract class CommonObject
|
||||
{
|
||||
global $conf,$langs,$user,$object,$hookmanager;
|
||||
global $form,$bc,$bcdd;
|
||||
global $object_rights, $disableedit, $disablemove; // TODO We should not use global var for this !
|
||||
global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
|
||||
|
||||
$object_rights = $this->getRights();
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
|
||||
* $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
|
||||
* $object_rights->creer initialized from = $object->getRights()
|
||||
* $disableedit, $disablemove
|
||||
* $disableedit, $disablemove, $disableremove
|
||||
*
|
||||
* $type, $text, $description, $line
|
||||
*/
|
||||
@ -46,7 +46,6 @@ if (empty($forceall)) $forceall=0;
|
||||
if (empty($senderissupplier)) $senderissupplier=0;
|
||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||
if (empty($usemargins)) $usemargins=0;
|
||||
|
||||
?>
|
||||
<?php $coldisplay=0; ?>
|
||||
<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
|
||||
@ -216,7 +215,7 @@ if (empty($usemargins)) $usemargins=0;
|
||||
|
||||
<td class="linecoldelete" align="center"><?php $coldisplay++; ?>
|
||||
<?php
|
||||
if ($this->situation_counter == 1 || !$this->situation_cycle_ref) {
|
||||
if (($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) {
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=ask_deleteline&lineid=' . $line->id . '">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user