mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 19:02:35 +01:00
Merge branch 'new_recurring_invoice' of
https://github.com/atm-ph/dolibarr into atm-ph-new_recurring_invoice Conflicts: htdocs/install/mysql/migration/3.9.0-4.0.0.sql
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
@@ -83,7 +84,20 @@ class FactureRec extends Facture
|
||||
// Clean parameters
|
||||
$this->titre=trim($this->titre);
|
||||
$this->usenewprice=empty($this->usenewprice)?0:$this->usenewprice;
|
||||
|
||||
|
||||
// No frequency defined then no next date to execution
|
||||
if (empty($this->frequency))
|
||||
{
|
||||
$this->frequency=0;
|
||||
$this->date_when=NULL;
|
||||
}
|
||||
|
||||
|
||||
$this->frequency=abs($this->frequency);
|
||||
$this->nb_gen_done=0;
|
||||
$this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max;
|
||||
$this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Charge facture modele
|
||||
@@ -105,9 +119,17 @@ 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";
|
||||
$sql.= ", frequency";
|
||||
$sql.= ", unit_frequency";
|
||||
$sql.= ", date_when";
|
||||
$sql.= ", date_last_gen";
|
||||
$sql.= ", nb_gen_done";
|
||||
$sql.= ", nb_gen_max";
|
||||
$sql.= ", auto_validate";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->titre."'";
|
||||
$sql.= ", ".$facsrc->socid;
|
||||
@@ -119,9 +141,17 @@ 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;
|
||||
$sql.= ", ".$this->frequency;
|
||||
$sql.= ", '".$this->db->escape($this->unit_frequency)."'";
|
||||
$sql.= ", ".(!empty($this->date_when)?"'".$this->db->idate($this->date_when)."'":'NULL');
|
||||
$sql.= ", ".(!empty($this->date_last_gen)?"'".$this->db->idate($this->date_last_gen)."'":'NULL');
|
||||
$sql.= ", ".$this->nb_gen_done;
|
||||
$sql.= ", ".$this->nb_gen_max;
|
||||
$sql.= ", ".$this->auto_validate;
|
||||
$sql.= ")";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@@ -197,7 +227,9 @@ 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';
|
||||
@@ -248,6 +280,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;
|
||||
@@ -255,6 +288,14 @@ class FactureRec extends Facture
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->rang = $obj->rang;
|
||||
$this->special_code = $obj->special_code;
|
||||
$this->frequency = $obj->frequency;
|
||||
$this->unit_frequency = $obj->unit_frequency;
|
||||
$this->date_when = $obj->date_when;
|
||||
$this->date_last_gen = $obj->date_last_gen;
|
||||
$this->nb_gen_done = $obj->nb_gen_done;
|
||||
$this->nb_gen_max = $obj->nb_gen_max;
|
||||
$this->usenewprice = $obj->usenewprice;
|
||||
$this->auto_validate = $obj->auto_validate;
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
|
||||
|
||||
@@ -468,7 +509,7 @@ class FactureRec extends Facture
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
|
||||
$product_type=$type;
|
||||
if ($fk_product)
|
||||
{
|
||||
@@ -529,6 +570,63 @@ class FactureRec extends Facture
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next date of
|
||||
*
|
||||
* @return timestamp false if KO, timestamp if OK
|
||||
*/
|
||||
function getNextDate()
|
||||
{
|
||||
if (empty($this->date_when)) return false;
|
||||
return dol_time_plus_duree(strtotime($this->date_when), $this->frequency, $this->unit_frequency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all recurrents invoices
|
||||
*
|
||||
* @return int number of created invoices
|
||||
*/
|
||||
function createRecurringInvoices()
|
||||
{
|
||||
global $db,$user;
|
||||
|
||||
$nb_create=0;
|
||||
|
||||
$today = date('Y-m-d 23:59:59');
|
||||
|
||||
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_rec';
|
||||
$sql.= ' WHERE date_when IS NOT NULL AND frequency > 0';
|
||||
$sql.= ' AND date_when <= "'.$db->escape($today).'"';
|
||||
$sql.= ' AND nb_gen_done < nb_gen_max';
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($line = $db->fetch_object($resql))
|
||||
{
|
||||
$facturerec = new FactureRec($db);
|
||||
$facturerec->fetch($line->rowid);
|
||||
|
||||
$facture = new Facture($db);
|
||||
$result = $facture->createFromRec($user, $facturerec);
|
||||
|
||||
// >0 create and validate if auto_validate
|
||||
// =0 create but not validate if auto_validate
|
||||
// <0 broken
|
||||
if ($result >= 0)
|
||||
{
|
||||
$next_date = $facturerec->getNextDate();
|
||||
$facturerec->setNextDate($next_date,1);
|
||||
|
||||
$nb_create++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $nb_create;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
@@ -601,4 +699,144 @@ 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
|
||||
* @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function setNextDate($date, $increment_nb_gen_done=0)
|
||||
{
|
||||
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.'"';
|
||||
if ($increment_nb_gen_done>0) $sql.= ', nb_gen_done = nb_gen_done + 1';
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -917,6 +919,60 @@ class Facture extends CommonInvoice
|
||||
else return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new invoice in database from facturerec
|
||||
*
|
||||
* @param User $user Object user that ask creation
|
||||
* @param FactureRec $facturerec Object facturerec source
|
||||
* @return int <0 if KO, 0 if not validate, >0 if OK
|
||||
*/
|
||||
function createFromRec($user, $facturerec)
|
||||
{
|
||||
|
||||
// Clean parameters
|
||||
$this->type = self::TYPE_STANDARD;
|
||||
$this->brouillon = 1;
|
||||
|
||||
// Charge facture source
|
||||
$facture=new Facture($facturerec->db);
|
||||
|
||||
$facture->socid = $facturerec->socid;
|
||||
$facture->date = dol_mktime(12, 0, 0, date('m'), date('d'), date('Y'));
|
||||
$facture->note_public = $facturerec->note_public;
|
||||
$facture->note_private = $facturerec->note_private;
|
||||
$facture->fk_project = $facturerec->fk_project;
|
||||
$facture->fk_account = $facturerec->fk_account;
|
||||
$facture->cond_reglement_id = $facturerec->cond_reglement_id;
|
||||
$facture->mode_reglement_id = $facturerec->mode_reglement_id;
|
||||
|
||||
$new_date_lim_reglement = $facture->calculate_date_lim_reglement();
|
||||
$facture->date_lim_reglement = $new_date_lim_reglement;
|
||||
|
||||
$facture->remise_absolue = $facturerec->remise_absolue;
|
||||
$facture->remise_percent = $facturerec->remise_percent;
|
||||
|
||||
$facture->lines = $facturerec->lines; // Tableau des lignes de factures
|
||||
|
||||
// Loop on each line of new invoice
|
||||
foreach($facture->lines as $i => $line)
|
||||
{
|
||||
$facture->lines[$i]->fk_prev_id = $facturerec->lines[$i]->rowid;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::createFromRec socid=".$this->socid." nboflines=".count($facture->lines));
|
||||
|
||||
$facid = $facture->create($user);
|
||||
if ($facid <= 0) return -1;
|
||||
|
||||
if ($facturerec->auto_validate)
|
||||
{
|
||||
$result = $facture->validate($user);
|
||||
if ($result<=0) return 0;
|
||||
}
|
||||
|
||||
return $facid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
|
||||
@@ -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
|
||||
@@ -75,16 +82,47 @@ if ($action == 'add')
|
||||
$error++;
|
||||
}
|
||||
|
||||
$frequency=GETPOST('frequency', 'int');
|
||||
$reyear=GETPOST('reyear');
|
||||
$remonth=GETPOST('remonth');
|
||||
$reday=GETPOST('reday');
|
||||
$nb_gen_max=GETPOST('nb_gen_max', 'int');
|
||||
|
||||
if (GETPOST('frequency'))
|
||||
{
|
||||
if (empty($reyear) || empty($remonth) || empty($reday))
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
if (empty($nb_gen_max))
|
||||
{
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("MaxPeriodNumber")), null, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$object->titre = GETPOST('titre', 'alpha');
|
||||
$object->note_private = GETPOST('note_private');
|
||||
$object->usenewprice = GETPOST('usenewprice');
|
||||
|
||||
|
||||
$object->frequency = $frequency;
|
||||
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
||||
$object->nb_gen_max = $nb_gen_max;
|
||||
$object->auto_validate = GETPOST('auto_validate', 'int');
|
||||
|
||||
$date_next_execution = dol_mktime(12, 0, 0, $remonth, $reday, $reyear);
|
||||
$object->date_when = $date_next_execution;
|
||||
|
||||
if ($object->create($user, $id) > 0)
|
||||
{
|
||||
$id = $object->id;
|
||||
$action = '';
|
||||
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,12 +135,59 @@ if ($action == 'add')
|
||||
// Delete
|
||||
if ($action == 'delete' && $user->rights->facture->supprimer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->delete();
|
||||
$id = 0 ;
|
||||
header("Location: " . $_SERVER['PHP_SELF'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
@@ -134,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 '<table class="border" width="100%">';
|
||||
|
||||
@@ -181,6 +267,46 @@ if ($action == 'create')
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Project
|
||||
if ($object->fk_account > 0)
|
||||
{
|
||||
print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
|
||||
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Recurrence
|
||||
$title = $langs->trans("Recurrence");
|
||||
print load_fiche_titre($title);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Frequency
|
||||
print "<tr><td>".$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
|
||||
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency')?GETPOST('unit_frequency'):'m'));
|
||||
print "</td></tr>";
|
||||
|
||||
// First date of execution for cron
|
||||
print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>";
|
||||
$date_next_execution = isset($date_next_execution) ? $date_next_execution : dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
print $form->select_date($date_next_execution, '', 0, 0, '', "add", 1, 1, 1);
|
||||
print "</td></tr>";
|
||||
|
||||
// Number max of generation
|
||||
print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>";
|
||||
print "<input type='text' name='nb_gen_max' value='' size='5' />";
|
||||
print "</td></tr>";
|
||||
|
||||
// Auto validate the invoice
|
||||
print "<tr><td>".$langs->trans("InvoiceAutoValidate")."</td><td>";
|
||||
print $form->selectyesno('auto_validate', 0, 1);
|
||||
print "</td></tr>";
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
@@ -394,178 +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 '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="4">'.$object->titre.'</td>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td>';
|
||||
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1,'customer').'</td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("Author").'</td><td colspan="3">'.$author->getFullName($langs)."</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td colspan="3"><b>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td colspan="3">'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Payment term
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
print '</td>';
|
||||
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && ! empty($object->brouillon) && $user->rights->facture->creer)
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
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 '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="4">'.$object->titre.'</td>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td>';
|
||||
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1,'customer').'</td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("Author").'</td><td colspan="3">'.$author->getFullName($langs)."</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
print '<td colspan="3"><b>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</b></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AmountVAT").'</td><td colspan="3">'.price($object->total_tva,'',$langs,1,-1,-1,$conf->currency).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc,'',$langs,1,-1,-1,$conf->currency).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Payment term
|
||||
print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">';
|
||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none');
|
||||
print "</td></tr>";
|
||||
|
||||
// Payment mode
|
||||
print '<tr><td>'.$langs->trans("PaymentMode").'</td><td colspan="3">';
|
||||
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id,'none');
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Comment").'</td><td colspan="3">'.nl2br($object->note_private)."</td></tr>";
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="center">'.$langs->trans("ReductionShort").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
print '<td align="left">'.$langs->trans("Unit").'</td>';
|
||||
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');
|
||||
}
|
||||
print '</tr>';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
$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 "<tr ".$bc[$var].">";
|
||||
if ($object->lines[$i]->fk_product > 0)
|
||||
{
|
||||
print '<td>';
|
||||
print '<a name="'.$object->lines[$i]->id.'"></a>'; // 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)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->desc):'';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
|
||||
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.= ' <strong>'.$object->lines[$i]->label.'</strong>';
|
||||
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 '</td>';
|
||||
}
|
||||
print '<td align="right">'.price($object->lines[$i]->price).'</td>';
|
||||
print '<td align="center">'.$object->lines[$i]->remise_percent.' %</td>';
|
||||
print '<td align="center">'.$object->lines[$i]->qty.'</td>';
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
print "<td align=\"left\">".$object->lines[$i]->getLabelOfUnit()."</td>";
|
||||
}
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
|
||||
{
|
||||
echo '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
|
||||
}
|
||||
|
||||
if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
// Payment mode
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode' && ! empty($object->brouillon) && $user->rights->facture->creer)
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
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 '</td></tr>';
|
||||
|
||||
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
|
||||
print '</td><td colspan="5">';
|
||||
print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':60');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled)) {
|
||||
$langs->load('projects');
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($action != 'classify') {
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=classify&facid=' . $object->id . '">';
|
||||
print img_edit($langs->trans('SetProject'), 1);
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
|
||||
print '</td><td colspan="3">';
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Bank Account
|
||||
print '<tr><td class="nowrap">';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon))
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
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 "</td>";
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Recurrence
|
||||
*/
|
||||
$title = $langs->trans("Recurrence");
|
||||
print load_fiche_titre($title);
|
||||
|
||||
print '<div class="tabBar">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// if "frequency" is empty or = 0, the reccurence is disabled
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Frequency');
|
||||
print '</td>';
|
||||
if ($action != 'editfrequency' && ! empty($object->brouillon) && $user->rights->facture->creer)
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editfrequency&facid=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editfrequency')
|
||||
{
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"] . '?facid=' . $object->id.'">';
|
||||
print '<input type="hidden" name="action" value="setfrequency">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency?$object->unit_frequency:'m'));
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Date when
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer);
|
||||
print '</td><td colspan="5">';
|
||||
print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'datepicker');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Max period / Rest period
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
|
||||
print '</td><td colspan="5">';
|
||||
print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '<tr><td width="25%">'.$langs->trans("RestPeriodNumber").'</td>';
|
||||
print '<td>'.($object->nb_gen_max-$object->nb_gen_done).'</td>';
|
||||
|
||||
// Auto validate
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey($langs->trans("InvoiceAutoValidate"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
|
||||
print '</td><td colspan="5">';
|
||||
$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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '<br />';
|
||||
|
||||
/*
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="center">'.$langs->trans("ReductionShort").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td>';
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
print '<td align="left">'.$langs->trans("Unit").'</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$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 "<tr ".$bc[$var].">";
|
||||
if ($object->lines[$i]->fk_product > 0)
|
||||
{
|
||||
print '<td>';
|
||||
print '<a name="'.$object->lines[$i]->id.'"></a>'; // 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)?'<br>'.dol_htmlentitiesbr($object->lines[$i]->desc):'';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>';
|
||||
|
||||
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.= ' <strong>'.$object->lines[$i]->label.'</strong>';
|
||||
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 '</td>';
|
||||
}
|
||||
print '<td align="right">'.price($object->lines[$i]->price).'</td>';
|
||||
print '<td align="center">'.$object->lines[$i]->remise_percent.' %</td>';
|
||||
print '<td align="center">'.$object->lines[$i]->qty.'</td>';
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
print "<td align=\"left\">".$object->lines[$i]->getLabelOfUnit()."</td>";
|
||||
}
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer)
|
||||
{
|
||||
echo '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
|
||||
}
|
||||
|
||||
if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2322,7 +2322,7 @@ abstract class CommonObject
|
||||
{
|
||||
$error++;
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->error[]=$this->db->lasterror();
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -212,4 +212,23 @@ ALTER TABLE llx_propaldet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT
|
||||
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1;
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
|
||||
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN fk_multicurrency integer;
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN multicurrency_code varchar(255);
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0;
|
||||
ALTER TABLE llx_facturedet_rec ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0;
|
||||
|
||||
|
||||
@@ -46,10 +46,17 @@ 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, -- bank account id
|
||||
note_private text,
|
||||
note_public text,
|
||||
|
||||
fk_multicurrency integer,
|
||||
multicurrency_code varchar(255),
|
||||
multicurrency_tx double(24,8) DEFAULT 1,
|
||||
multicurrency_total_ht double(24,8) DEFAULT 0,
|
||||
multicurrency_total_tva double(24,8) DEFAULT 0,
|
||||
multicurrency_total_ttc double(24,8) DEFAULT 0,
|
||||
|
||||
usenewprice integer DEFAULT 0, -- update invoice with current price of product instead of recorded price
|
||||
frequency integer, -- frequency (for example: 3 for every 3 month)
|
||||
unit_frequency varchar(2) DEFAULT 'm', -- 'm' for month (date_when must be a day <= 28), 'y' for year, ...
|
||||
@@ -57,5 +64,6 @@ create table llx_facture_rec
|
||||
date_when datetime DEFAULT NULL, -- date for next gen (when an invoice is generated, this field must be updated with next date)
|
||||
date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice)
|
||||
nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented)
|
||||
nb_gen_max integer DEFAULT NULL -- maximum number of generation
|
||||
nb_gen_max integer DEFAULT NULL, -- maximum number of generation
|
||||
auto_validate integer DEFAULT 0 -- 0 to create in draft, 1 to create and validate the new invoice
|
||||
)ENGINE=innodb;
|
||||
|
||||
@@ -48,5 +48,12 @@ create table llx_facturedet_rec
|
||||
special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0, -- ordre d'affichage
|
||||
fk_contract_line integer NULL, -- id of contract line when predefined invoice comes from contract lines
|
||||
fk_unit integer DEFAULT NULL
|
||||
fk_unit integer DEFAULT NULL,
|
||||
|
||||
fk_multicurrency integer,
|
||||
multicurrency_code varchar(255),
|
||||
multicurrency_subprice double(24,8) DEFAULT 0,
|
||||
multicurrency_total_ht double(24,8) DEFAULT 0,
|
||||
multicurrency_total_tva double(24,8) DEFAULT 0,
|
||||
multicurrency_total_ttc double(24,8) DEFAULT 0
|
||||
)ENGINE=innodb;
|
||||
|
||||
@@ -306,7 +306,14 @@ AmountPaymentDistributedOnInvoice=Payment amount distributed on invoice
|
||||
PaymentNote=Payment note
|
||||
ListOfPreviousSituationInvoices=List of previous situation invoices
|
||||
ListOfNextSituationInvoices=List of next situation invoices
|
||||
|
||||
FrequencyPer_d=Every %s days
|
||||
FrequencyPer_m=Every %s months
|
||||
FrequencyPer_y=Every %s years
|
||||
toolTipFrequency=Examples:<br /><b>Set 7 / day</b>: give a new invoice every 7 days<br /><b>Set 3 / month</b>: give a new invoice every 3 month
|
||||
NextDateToExecution=Next date to execution
|
||||
MaxPeriodNumber=Max period number
|
||||
RestPeriodNumber=Rest period number
|
||||
InvoiceAutoValidate=Automatically validate invoice
|
||||
# PaymentConditions
|
||||
PaymentConditionShortRECEP=Immediate
|
||||
PaymentConditionRECEP=Immediate
|
||||
|
||||
Reference in New Issue
Block a user