diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 91e3388c8ff..26659db4796 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -119,6 +119,7 @@ class FactureRec extends Facture
$sql.= ", note_public";
$sql.= ", fk_user_author";
$sql.= ", fk_projet";
+ $sql.= ", fk_account";
$sql.= ", fk_cond_reglement";
$sql.= ", fk_mode_reglement";
$sql.= ", usenewprice";
@@ -140,6 +141,7 @@ class FactureRec extends Facture
$sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql.= ", '".$user->id."'";
$sql.= ", ".(! empty($facsrc->fk_project)?"'".$facsrc->fk_project."'":"null");
+ $sql.= ", ".(! empty($facsrc->fk_account)?"'".$facsrc->fk_account."'":"null");
$sql.= ", '".$facsrc->cond_reglement_id."'";
$sql.= ", '".$facsrc->mode_reglement_id."'";
$sql.= ", ".$this->usenewprice;
@@ -225,11 +227,33 @@ class FactureRec extends Facture
$sql = 'SELECT f.titre,f.fk_soc,f.amount,f.tva,f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise';
$sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.note_private, f.note_public, f.fk_user_author';
- $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement';
+ $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet';
+ $sql.= ', f.fk_account';
$sql.= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate';
$sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
$sql.= ', el.fk_source';
+
+ /*
+ $sql.= ', f.remise_percent, f.remise_absolue, f.remise';
+ $sql.= ', f.datef as df';
+ $sql.= ', f.date_lim_reglement as dlr';
+ $sql.= ', f.datec as datec';
+ $sql.= ', f.date_valid as datev';
+ $sql.= ', f.tms as datem';
+ $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
+ $sql.= ', f.fk_facture_source';
+ $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
+ $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
+ $sql.= ', f.fk_account';
+ $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc";
+ $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
+ $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
+ $sql.= ', f.fk_incoterms, f.location_incoterms';
+ $sql.= ", i.libelle as libelle_incoterms";
+ */
+
+
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id';
@@ -277,6 +301,7 @@ class FactureRec extends Facture
$this->cond_reglement = $obj->cond_reglement_libelle;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->fk_project = $obj->fk_projet;
+ $this->fk_account = $obj->fk_account;
$this->fk_facture_source = $obj->fk_facture_source;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
@@ -690,4 +715,142 @@ class FactureRec extends Facture
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
+
+ /**
+ * Update frequency and unit
+ *
+ * @param int $frequency value of frequency
+ * @param string $unit unit of frequency (d, m, y)
+ * @return int <0 if KO, >0 if OK
+ */
+ function setFrequencyAndUnit($frequency=0,$unit='')
+ {
+ if (! $this->table_element)
+ {
+ dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined",LOG_ERR);
+ return -1;
+ }
+
+ if (empty($frequency) && empty($unit))
+ {
+ dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency and unit not defined",LOG_ERR);
+ return -2;
+ }
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ if (!empty($frequency)) $sql.= ' SET frequency = '.$frequency;
+ if (!empty($unit))
+ {
+ if (!empty($frequency)) $sql .= ',';
+ else $sql .= ' SET';
+ $sql.= ' unit_frequency = "'.$this->db->escape($unit).'"';
+ }
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ if (!empty($frequency)) $this->frequency = $frequency;
+ if (!empty($unit)) $this->unit_frequency = $unit;
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Update the next date of execution
+ *
+ * @param datetime $date date of execution (format timestamp)
+ * @return int <0 if KO, >0 if OK
+ */
+ function setNextDate($date)
+ {
+ if (! $this->table_element)
+ {
+ dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined",LOG_ERR);
+ return -1;
+ }
+ $date = $this->db->idate($date);
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql.= ' SET date_when = "'.$date.'"';
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->date_when = $date;
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Update the maximum period
+ *
+ * @param int $nb number of maximum period
+ * @return int <0 if KO, >0 if OK
+ */
+ function setMaxPeriod($nb)
+ {
+ if (! $this->table_element)
+ {
+ dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined",LOG_ERR);
+ return -1;
+ }
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql.= ' SET nb_gen_max = '.$nb;
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->nb_gen_max = $nb;
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Update the auto validate invoice
+ *
+ * @param int $validate 0 to create in draft, 1 to create and validate invoice
+ * @return int <0 if KO, >0 if OK
+ */
+ function setAutoValidate($validate)
+ {
+ if (! $this->table_element)
+ {
+ dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined",LOG_ERR);
+ return -1;
+ }
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql.= ' SET auto_validate = '.$validate;
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->auto_validate = $validate;
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index edb22982843..a10202470c4 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -278,6 +278,8 @@ class Facture extends CommonInvoice
$result=$_facrec->fetch($this->fac_rec);
$this->fk_project = $_facrec->fk_project;
+ $this->fk_account = $_facrec->fk_account;
+ $this->note_private = $_facrec->note_private;
$this->cond_reglement_id = $_facrec->cond_reglement_id;
$this->mode_reglement_id = $_facrec->mode_reglement_id;
$this->remise_absolue = $_facrec->remise_absolue;
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index b9c3b58a224..ae1e74829d9 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -58,7 +58,14 @@ if ($sortfield == "")
$sortfield="f.datef";
$object = new FactureRec($db);
-
+if ($id > 0 && $action != 'create' && $action != 'add')
+{
+ $ret = $object->fetch($id);
+ if (!$ret)
+ {
+ setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
+ }
+}
/*
* Actions
@@ -134,6 +141,54 @@ if ($action == 'delete' && $user->rights->facture->supprimer)
+// Update field
+// Set condition
+if ($action == 'setconditions' && $user->rights->facture->creer)
+{
+ $result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
+
+}
+// Set mode
+elseif ($action == 'setmode' && $user->rights->facture->creer)
+{
+ $result=$object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
+}
+// Set project
+elseif ($action == 'classin' && $user->rights->facture->creer)
+{
+ $object->setProject(GETPOST('projectid', 'int'));
+}
+// Set bank account
+elseif ($action == 'setbankaccount' && $user->rights->facture->creer)
+{
+ $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
+}
+// Set frequency and unit frequency
+elseif ($action == 'setfrequency' && $user->rights->facture->creer)
+{
+ $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha'));
+}
+// Set next date of execution
+elseif ($action == 'setdate_when' && $user->rights->facture->creer)
+{
+ $date = dol_mktime(12, 0, 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
+ if (!empty($date)) $object->setNextDate($date);
+}
+// Set max period
+elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer)
+{
+ $object->setMaxPeriod(GETPOST('nb_gen_max', 'int'));
+}
+// Set auto validate
+elseif ($action == 'setauto_validate' && $user->rights->facture->creer)
+{
+ $object->setAutoValidate(GETPOST('auto_validate', 'int'));
+}
+// Set note
+$permissionnote=$user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
+
+
/*
* View
*/
@@ -164,6 +219,7 @@ if ($action == 'create')
$rowspan=4;
if (! empty($conf->projet->enabled) && $object->fk_project > 0) $rowspan++;
+ if ($object->fk_account > 0) $rowspan++;
print '
';
@@ -211,6 +267,14 @@ if ($action == 'create')
print "";
}
+ // Project
+ if ($object->fk_account > 0)
+ {
+ print "| ".$langs->trans('BankAccount')." | ";
+ $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
+ print " |
";
+ }
+
print "
";
print '
';
@@ -456,206 +520,323 @@ else
/*
* View mode
*/
- if ($id > 0)
+ if ($object->id > 0)
{
- if ($object->fetch($id) > 0)
+ $object->fetch_thirdparty();
+
+ $author = new User($db);
+ $author->fetch($object->user_author);
+
+ $head=array();
+ $h=0;
+ $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
+ $head[$h][1] = $langs->trans("CardBill");
+ $head[$h][2] = 'card';
+
+ dol_fiche_head($head, 'card', $langs->trans("PredefinedInvoices"),0,'bill'); // Add a div
+
+ print '';
+
+ print '| '.$langs->trans("Ref").' | ';
+ print ''.$object->titre.' | ';
+
+ print '
| '.$langs->trans("Customer").' | ';
+ print ''.$object->thirdparty->getNomUrl(1,'customer').' |
';
+
+ print "| ".$langs->trans("Author").' | '.$author->getFullName($langs)." |
";
+
+ print '| '.$langs->trans("AmountHT").' | ';
+ print ''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).' | ';
+ print '
';
+
+ print '| '.$langs->trans("AmountVAT").' | '.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).' | ';
+ print '
';
+ print '| '.$langs->trans("AmountTTC").' | '.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).' | ';
+ print '
';
+
+ // Payment term
+ print '| ';
+ print '';
+ print ' | ';
+ if ($object->type != Facture::TYPE_CREDIT_NOTE)
{
- $object->fetch_thirdparty();
-
- $author = new User($db);
- $author->fetch($object->user_author);
-
- $head=array();
- $h=0;
- $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
- $head[$h][1] = $langs->trans("CardBill");
- $head[$h][2] = 'card';
-
- dol_fiche_head($head, 'card', $langs->trans("PredefinedInvoices"),0,'bill'); // Add a div
-
- print '';
-
- print '| '.$langs->trans("Ref").' | ';
- print ''.$object->titre.' | ';
-
- print ' | '.$langs->trans("Customer").' | ';
- print ''.$object->thirdparty->getNomUrl(1,'customer').' | ';
-
- print "| ".$langs->trans("Author").' | '.$author->getFullName($langs)." | ";
-
- print '| '.$langs->trans("AmountHT").' | ';
- print ''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).' | ';
- print ' ';
-
- print '| '.$langs->trans("AmountVAT").' | '.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).' | ';
- print ' ';
- print '| '.$langs->trans("AmountTTC").' | '.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).' | ';
- print ' ';
-
- // Payment term
- print '| '.$langs->trans("PaymentConditions").' | ';
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none');
- print " | ";
-
- // Payment mode
- print '| '.$langs->trans("PaymentMode").' | ';
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none');
- print " | ";
-
- print '| '.$langs->trans("Comment").' | '.nl2br($object->note_private)." | ";
-
- print " ";
-
- print '';
-
- /*
- * Recurrence
- */
- if ($object->frequency > 0)
- {
- $title = $langs->trans("Recurrence");
- print load_fiche_titre($title);
-
- print '';
- print ' ';
-
- print '| '.$langs->trans("Frequency").' | ';
- print ''.$langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency).' | ';
-
- print ' | '.$langs->trans("NextDateToExecution").' | ';
- print ''.dol_print_date($object->date_when, 'daytext').' | ';
-
- print ' | '.$langs->trans("MaxPeriodNumber").' / '.$langs->trans("RestPeriodNumber").' | ';
- print ''.$object->nb_gen_max.' / '.($object->nb_gen_max-$object->nb_gen_done).' | ';
-
- print ' | '.$langs->trans("InvoiceAutoValidate").' | ';
- print ''.yn($object->auto_validate).' | ';
-
- print ' ';
- print ' ';
- print ' ';
+ if ($action == 'editconditions') {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id');
+ } else {
+ $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->cond_reglement_id, 'none');
}
+ } else {
+ print ' ';
+ }
+ print ' |
';
- /*
- * Lines
- */
-
- $title = $langs->trans("ProductsAndServices");
- if (empty($conf->service->enabled))
- $title = $langs->trans("Products");
- else if (empty($conf->product->enabled))
- $title = $langs->trans("Services");
-
- print load_fiche_titre($title);
-
- print '';
- print '';
- print '| '.$langs->trans("Description").' | ';
- print ''.$langs->trans("Price").' | ';
- print ''.$langs->trans("ReductionShort").' | ';
- print ''.$langs->trans("Qty").' | ';
- if ($conf->global->PRODUCT_USE_UNITS) {
- print ''.$langs->trans("Unit").' | ';
- }
- print '
';
-
- $num = count($object->lines);
- $i = 0;
- $var=true;
- while ($i < $num)
- {
- $var=!$var;
-
- $product_static=new Product($db);
-
- // Show product and description
- $type=(isset($object->lines[$i]->product_type)?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type);
- // Try to enhance type detection using date_start and date_end for free lines when type
- // was not saved.
- if (! empty($objp->date_start)) $type=1;
- if (! empty($objp->date_end)) $type=1;
-
- // Show line
- print "";
- if ($object->lines[$i]->fk_product > 0)
- {
- print '';
- print ''; // ancre pour retourner sur la ligne
-
- // Show product and description
- $product_static->type=$object->lines[$i]->fk_product_type;
- $product_static->id=$object->lines[$i]->fk_product;
- $product_static->ref=$object->lines[$i]->product_ref;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.(! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
- $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->desc));
- print $form->textwithtooltip($text,$description,3,'','',$i);
-
- // Show range
- print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
-
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
- print (! empty($object->lines[$i]->desc) && $object->lines[$i]->desc!=$fac->lines[$i]->product_label)?' '.dol_htmlentitiesbr($object->lines[$i]->desc):'';
-
- print ' | ';
- }
- else
- {
- print '';
-
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
-
- if (! empty($object->lines[$i]->label)) {
-
- $text.= ' '.$object->lines[$i]->label.'';
- print $form->textwithtooltip($text,dol_htmlentitiesbr($object->lines[$i]->desc),3,'','',$i);
-
- } else {
-
- print $text.' '.nl2br($object->lines[$i]->desc);
- }
-
- // Show range
- print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
-
- print ' | ';
- }
- print ''.price($object->lines[$i]->price).' | ';
- print ''.$object->lines[$i]->remise_percent.' % | ';
- print ''.$object->lines[$i]->qty.' | ';
- if ($conf->global->PRODUCT_USE_UNITS) {
- print "".$object->lines[$i]->getLabelOfUnit()." | ";
- }
- print "
\n";
- $i++;
- }
- print '
';
-
-
-
- /**
- * Barre d'actions
- */
- print '';
-
- if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
- {
- echo '
';
- }
-
- if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
- {
- print '
';
- }
-
- print '
';
+ // Payment mode
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editmode')
+ {
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT');
}
else
{
- print $langs->trans("ErrorRecordNotFound");
+ $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT');
}
+ print ' |
';
+
+
+ print '| ';
+ print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
+ print ' | ';
+ print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60');
+ print ' | ';
+ print '
';
+
+ // Project
+ if (! empty($conf->projet->enabled)) {
+ $langs->load('projects');
+ print '';
+ print '| ';
+
+ print '';
+
+ print ' | ';
+ if ($action == 'classify') {
+ $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
+ } else {
+ $form->form_project($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
+ }
+ print ' | ';
+ print '
';
+ }
+
+ // Bank Account
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editbankaccount')
+ {
+ $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
+ }
+ else
+ {
+ $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
+ }
+ print " | ";
+ print '
';
+
+
+ print "
";
+
+ print '';
+
+ /*
+ * Recurrence
+ */
+ $title = $langs->trans("Recurrence");
+ print load_fiche_titre($title);
+
+ print '';
+ print '
';
+
+ // if "frequency" is empty or = 0, the reccurence is disabled
+ print '| ';
+ print '';
+ print ' | ';
+ if ($action == 'editfrequency')
+ {
+ print '';
+ }
+ else
+ {
+ print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
+ }
+ print ' |
';
+
+ // Date when
+ print '| ';
+ print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer);
+ print ' | ';
+ print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker');
+ print ' | ';
+ print '
';
+
+
+ // Max period / Rest period
+ print '| ';
+ print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
+ print ' | ';
+ print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
+ print ' | ';
+ print '
';
+ print '| '.$langs->trans("RestPeriodNumber").' | ';
+ print ''.($object->nb_gen_max-$object->nb_gen_done).' | ';
+
+ // Auto validate
+ print '
| ';
+ print $form->editfieldkey($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
+ print ' | ';
+ $select = 'select;0:'.$langs->trans('No').',1:'.$langs->trans('Yes');
+ print $form->editfieldval($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select);
+ print ' | ';
+ print '
';
+
+ print '
';
+ print '
';
+ print '
';
+
+ /*
+ * Lines
+ */
+
+ $title = $langs->trans("ProductsAndServices");
+ if (empty($conf->service->enabled))
+ $title = $langs->trans("Products");
+ else if (empty($conf->product->enabled))
+ $title = $langs->trans("Services");
+
+ print load_fiche_titre($title);
+
+ print '';
+ print '';
+ print '| '.$langs->trans("Description").' | ';
+ print ''.$langs->trans("Price").' | ';
+ print ''.$langs->trans("ReductionShort").' | ';
+ print ''.$langs->trans("Qty").' | ';
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ print ''.$langs->trans("Unit").' | ';
+ }
+ print '
';
+
+ $num = count($object->lines);
+ $i = 0;
+ $var=true;
+ while ($i < $num)
+ {
+ $var=!$var;
+
+ $product_static=new Product($db);
+
+ // Show product and description
+ $type=(isset($object->lines[$i]->product_type)?$object->lines[$i]->product_type:$object->lines[$i]->fk_product_type);
+ // Try to enhance type detection using date_start and date_end for free lines when type
+ // was not saved.
+ if (! empty($objp->date_start)) $type=1;
+ if (! empty($objp->date_end)) $type=1;
+
+ // Show line
+ print "";
+ if ($object->lines[$i]->fk_product > 0)
+ {
+ print '';
+ print ''; // ancre pour retourner sur la ligne
+
+ // Show product and description
+ $product_static->type=$object->lines[$i]->fk_product_type;
+ $product_static->id=$object->lines[$i]->fk_product;
+ $product_static->ref=$object->lines[$i]->product_ref;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.(! empty($object->lines[$i]->label)?$object->lines[$i]->label:$object->lines[$i]->product_label);
+ $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($object->lines[$i]->desc));
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+
+ // Show range
+ print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
+
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ print (! empty($object->lines[$i]->desc) && $object->lines[$i]->desc!=$fac->lines[$i]->product_label)?' '.dol_htmlentitiesbr($object->lines[$i]->desc):'';
+
+ print ' | ';
+ }
+ else
+ {
+ print '';
+
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($object->lines[$i]->label)) {
+
+ $text.= ' '.$object->lines[$i]->label.'';
+ print $form->textwithtooltip($text,dol_htmlentitiesbr($object->lines[$i]->desc),3,'','',$i);
+
+ } else {
+
+ print $text.' '.nl2br($object->lines[$i]->desc);
+ }
+
+ // Show range
+ print_date_range($object->lines[$i]->date_start, $object->lines[$i]->date_end);
+
+ print ' | ';
+ }
+ print ''.price($object->lines[$i]->price).' | ';
+ print ''.$object->lines[$i]->remise_percent.' % | ';
+ print ''.$object->lines[$i]->qty.' | ';
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ print "".$object->lines[$i]->getLabelOfUnit()." | ";
+ }
+ print "
\n";
+ $i++;
+ }
+ print '
';
+
+
+
+ /**
+ * Barre d'actions
+ */
+ print '';
+
+ if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
+ {
+ echo '
';
+ }
+
+ if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
+ {
+ print '
';
+ }
+
+ print '
';
+
}
else
{
diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
index 57f3c10ebe4..279db6998a4 100644
--- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
+++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql
@@ -213,6 +213,7 @@ ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAUL
ALTER TABLE llx_facture_rec ADD COLUMN auto_validate integer DEFAULT 0;
+ALTER TABLE llx_facture_rec ADD COLUMN fk_account integer DEFAULT 0;
ALTER TABLE llx_facture_rec ADD COLUMN fk_multicurrency integer;
ALTER TABLE llx_facture_rec ADD COLUMN multicurrency_code varchar(255);
diff --git a/htdocs/install/mysql/tables/llx_facture_rec.sql b/htdocs/install/mysql/tables/llx_facture_rec.sql
index 19fdb14516b..11e152bcfc2 100644
--- a/htdocs/install/mysql/tables/llx_facture_rec.sql
+++ b/htdocs/install/mysql/tables/llx_facture_rec.sql
@@ -46,7 +46,7 @@ create table llx_facture_rec
fk_cond_reglement integer DEFAULT 0, -- condition de reglement
fk_mode_reglement integer DEFAULT 0, -- mode de reglement (Virement, Prelevement)
date_lim_reglement date, -- date limite de reglement
-
+ fk_account integer,
note_private text,
note_public text,