Merge pull request #11831 from ptibogxiv/patch-255
NEW auto set closing date and user on invoice
This commit is contained in:
commit
bb974c3d6e
@ -2137,6 +2137,8 @@ class Facture extends CommonInvoice
|
|||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG);
|
dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET';
|
||||||
@ -2144,6 +2146,8 @@ class Facture extends CommonInvoice
|
|||||||
if (! $close_code) $sql.= ', paye=1';
|
if (! $close_code) $sql.= ', paye=1';
|
||||||
if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'";
|
if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'";
|
||||||
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
|
if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'";
|
||||||
|
$sql.= ', fk_user_closing = '.$user->id;
|
||||||
|
$sql.= ", date_closing = '".$this->db->idate($now)."'";
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -2195,7 +2199,9 @@ class Facture extends CommonInvoice
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||||
$sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null';
|
$sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null,';
|
||||||
|
$sql.= ' date_closing=null,';
|
||||||
|
$sql.= ' fk_user_closing=null';
|
||||||
$sql.= ' WHERE rowid = '.$this->id;
|
$sql.= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG);
|
dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG);
|
||||||
@ -3521,7 +3527,8 @@ class Facture extends CommonInvoice
|
|||||||
public function info($id)
|
public function info($id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,';
|
$sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,';
|
||||||
$sql.= ' fk_user_author, fk_user_valid';
|
$sql.= ' date_closing as dateclosing,';
|
||||||
|
$sql.= ' fk_user_author, fk_user_valid, fk_user_closing';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture as c';
|
||||||
$sql.= ' WHERE c.rowid = '.$id;
|
$sql.= ' WHERE c.rowid = '.$id;
|
||||||
|
|
||||||
@ -3544,9 +3551,17 @@ class Facture extends CommonInvoice
|
|||||||
$vuser->fetch($obj->fk_user_valid);
|
$vuser->fetch($obj->fk_user_valid);
|
||||||
$this->user_validation = $vuser;
|
$this->user_validation = $vuser;
|
||||||
}
|
}
|
||||||
|
if ($obj->fk_user_closing)
|
||||||
|
{
|
||||||
|
$cluser = new User($this->db);
|
||||||
|
$cluser->fetch($obj->fk_user_closing);
|
||||||
|
$this->user_closing = $cluser;
|
||||||
|
}
|
||||||
|
|
||||||
$this->date_creation = $this->db->jdate($obj->datec);
|
$this->date_creation = $this->db->jdate($obj->datec);
|
||||||
$this->date_modification = $this->db->jdate($obj->datem);
|
$this->date_modification = $this->db->jdate($obj->datem);
|
||||||
$this->date_validation = $this->db->jdate($obj->datev); // Should be in log table
|
$this->date_validation = $this->db->jdate($obj->datev);
|
||||||
|
$this->date_closing = $this->db->jdate($obj->dateclosing);
|
||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,6 +181,7 @@ $arrayfields=array(
|
|||||||
'rtp'=>array('label'=>"Rest", 'checked'=>0),
|
'rtp'=>array('label'=>"Rest", 'checked'=>0),
|
||||||
'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
|
'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
|
||||||
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
||||||
|
'f.date_closing'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500),
|
||||||
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -382,7 +383,7 @@ $sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_publ
|
|||||||
$sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
|
$sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
|
||||||
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
|
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
|
||||||
$sql.= ' f.paye as paye, f.fk_statut,';
|
$sql.= ' f.paye as paye, f.fk_statut,';
|
||||||
$sql.= ' f.datec as date_creation, f.tms as date_update,';
|
$sql.= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
|
||||||
if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
|
if($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
|
||||||
{
|
{
|
||||||
$sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,';
|
$sql.= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final,f.situation_cycle_ref,f.situation_counter,';
|
||||||
@ -497,7 +498,7 @@ if (! $sall)
|
|||||||
$sql.= ' f.localtax1, f.localtax2,';
|
$sql.= ' f.localtax1, f.localtax2,';
|
||||||
$sql.= ' f.datef, f.date_lim_reglement,';
|
$sql.= ' f.datef, f.date_lim_reglement,';
|
||||||
$sql.= ' f.paye, f.fk_statut,';
|
$sql.= ' f.paye, f.fk_statut,';
|
||||||
$sql.= ' f.datec, f.tms,';
|
$sql.= ' f.datec, f.tms, f.date_closing,';
|
||||||
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
|
$sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
|
||||||
$sql.= ' typent.code,';
|
$sql.= ' typent.code,';
|
||||||
$sql.= ' state.code_departement, state.nom,';
|
$sql.= ' state.code_departement, state.nom,';
|
||||||
@ -866,6 +867,12 @@ if ($resql)
|
|||||||
print '<td class="liste_titre right">';
|
print '<td class="liste_titre right">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
if (! empty($arrayfields['f.date_closing']['checked']))
|
||||||
|
{
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||||
|
|
||||||
@ -932,6 +939,7 @@ if ($resql)
|
|||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER["PHP_SELF"], "f.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER["PHP_SELF"], "f.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
|
if (! empty($arrayfields['f.date_closing']['checked'])) print_liste_field_titre($arrayfields['f.date_closing']['label'], $_SERVER["PHP_SELF"], "f.date_closing", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
|
||||||
if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder);
|
if (! empty($arrayfields['f.fk_statut']['checked'])) print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type,dynamount_payed", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
@ -1262,6 +1270,14 @@ if ($resql)
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
if (! $i) $totalarray['nbfield']++;
|
if (! $i) $totalarray['nbfield']++;
|
||||||
}
|
}
|
||||||
|
// Date closing
|
||||||
|
if (! empty($arrayfields['f.date_closing']['checked']))
|
||||||
|
{
|
||||||
|
print '<td align="center" class="nowrap">';
|
||||||
|
print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser');
|
||||||
|
print '</td>';
|
||||||
|
if (! $i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
// Status
|
// Status
|
||||||
if (! empty($arrayfields['f.fk_statut']['checked']))
|
if (! empty($arrayfields['f.fk_statut']['checked']))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -93,7 +93,8 @@ ALTER TABLE llx_extrafields ADD COLUMN printable boolean DEFAULT FALSE;
|
|||||||
ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final;
|
ALTER TABLE llx_facture ADD COLUMN retained_warranty real DEFAULT NULL after situation_final;
|
||||||
ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty;
|
ALTER TABLE llx_facture ADD COLUMN retained_warranty_date_limit date DEFAULT NULL after retained_warranty;
|
||||||
ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit;
|
ALTER TABLE llx_facture ADD COLUMN retained_warranty_fk_cond_reglement integer DEFAULT NULL after retained_warranty_date_limit;
|
||||||
|
ALTER TABLE llx_facture ADD COLUMN date_closing datetime DEFAULT NULL after date_valid;
|
||||||
|
ALTER TABLE llx_facture ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid;
|
||||||
|
|
||||||
ALTER TABLE llx_c_shipment_mode ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
ALTER TABLE llx_c_shipment_mode ADD COLUMN entity integer DEFAULT 1 NOT NULL;
|
||||||
|
|
||||||
@ -311,3 +312,4 @@ create table llx_fichinterdet_rec
|
|||||||
|
|
||||||
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type;
|
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL AFTER product_type;
|
||||||
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start;
|
ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL AFTER date_start;
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ create table llx_facture
|
|||||||
date_pointoftax date DEFAULT NULL, -- date point of tax (for GB)
|
date_pointoftax date DEFAULT NULL, -- date point of tax (for GB)
|
||||||
date_valid date, -- date validation
|
date_valid date, -- date validation
|
||||||
tms timestamp, -- date creation/modification
|
tms timestamp, -- date creation/modification
|
||||||
|
date_closing datetime, -- date de cloture
|
||||||
paye smallint DEFAULT 0 NOT NULL,
|
paye smallint DEFAULT 0 NOT NULL,
|
||||||
amount double(24,8) DEFAULT 0 NOT NULL,
|
amount double(24,8) DEFAULT 0 NOT NULL,
|
||||||
remise_percent real DEFAULT 0, -- remise relative
|
remise_percent real DEFAULT 0, -- remise relative
|
||||||
@ -62,6 +63,7 @@ create table llx_facture
|
|||||||
fk_user_author integer, -- user making creation
|
fk_user_author integer, -- user making creation
|
||||||
fk_user_modif integer, -- user making last change
|
fk_user_modif integer, -- user making last change
|
||||||
fk_user_valid integer, -- user validating
|
fk_user_valid integer, -- user validating
|
||||||
|
fk_user_closing integer, -- user closing
|
||||||
|
|
||||||
module_source varchar(32), -- name of module when invoice generated by a dedicated module (POS, ...)
|
module_source varchar(32), -- name of module when invoice generated by a dedicated module (POS, ...)
|
||||||
pos_source varchar(32), -- name of POS station when invoice is generated by a POS module
|
pos_source varchar(32), -- name of POS station when invoice is generated by a POS module
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user