2
0
forked from Wavyzz/dolibarr

NEW Add view of status of template invoice

This commit is contained in:
Laurent Destailleur
2017-09-10 20:47:45 +02:00
parent e7abb39ee2
commit 2ae135baf1
6 changed files with 113 additions and 37 deletions

View File

@@ -964,16 +964,19 @@ if ($id > 0)
$sql.= ', f.tva as total_tva'; $sql.= ', f.tva as total_tva';
$sql.= ', f.total_ttc'; $sql.= ', f.total_ttc';
$sql.= ', f.datec as dc'; $sql.= ', f.datec as dc';
$sql.= ', f.status as status'; $sql.= ', f.date_last_gen';
$sql.= ', f.frequency';
$sql.= ', f.unit_frequency';
$sql.= ', f.suspended as suspended';
$sql.= ', s.nom, s.rowid as socid'; $sql.= ', s.nom, s.rowid as socid';
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
$sql.= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,'; $sql.= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,';
$sql.= ' f.datec,'; $sql.= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
$sql.= ' f.status,'; $sql.= ' f.suspended,';
$sql.= ' s.nom, s.rowid'; $sql.= ' s.nom, s.rowid';
$sql.= " ORDER BY f.datec DESC"; $sql.= " ORDER BY f.date_last_gen, f.datec DESC";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
@@ -999,19 +1002,28 @@ if ($id > 0)
print '<td class="nowrap">'; print '<td class="nowrap">';
$invoicetemplate->id = $objp->id; $invoicetemplate->id = $objp->id;
$invoicetemplate->ref = $objp->ref; $invoicetemplate->ref = $objp->ref;
$invoicetemplate->statut = $objp->status; $invoicetemplate->suspended = $objp->suspended;
$invoicetemplate->frequency = $objp->frequency;
$invoicetemplate->unit_frequency = $objp->unit_frequency;
$invoicetemplate->total_ht = $objp->total_ht; $invoicetemplate->total_ht = $objp->total_ht;
$invoicetemplate->total_tva = $objp->total_tva; $invoicetemplate->total_tva = $objp->total_tva;
$invoicetemplate->total_ttc = $objp->total_ttc; $invoicetemplate->total_ttc = $objp->total_ttc;
print $invoicetemplate->getNomUrl(1); print $invoicetemplate->getNomUrl(1);
print '</td>'; print '</td>';
if ($objp->dc > 0) if ($objp->frequency && $objp->date_last_gen > 0)
{ {
print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->dc),'day').'</td>'; print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen),'day').'</td>';
} }
else else
{ {
print '<td align="right"><b>!!!</b></td>'; if ($objp->dc > 0)
{
print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->dc),'day').'</td>';
}
else
{
print '<td align="right"><b>!!!</b></td>';
}
} }
print '<td align="right" style="min-width: 60px">'; print '<td align="right" style="min-width: 60px">';
print price($objp->total_ht); print price($objp->total_ht);
@@ -1025,7 +1037,8 @@ if ($id > 0)
} }
print '<td align="right" class="nowrap" style="min-width: 60px">'; print '<td align="right" class="nowrap" style="min-width: 60px">';
print ($invoicetemplate->LibStatut(0,$invoicetemplate->statut,5,0)); print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - ';
print ($invoicetemplate->LibStatut($invoicetemplate->frequency,$invoicetemplate->suspended,5,0));
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@@ -248,7 +248,7 @@ class FactureRec extends CommonInvoice
*/ */
function fetch($rowid, $ref='', $ref_ext='', $ref_int='') function fetch($rowid, $ref='', $ref_ext='', $ref_int='')
{ {
$sql = 'SELECT f.rowid, f.entity, f.titre, f.status, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql = 'SELECT f.rowid, f.entity, f.titre, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc';
$sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise';
$sql.= ', f.date_lim_reglement as dlr'; $sql.= ', f.date_lim_reglement as dlr';
$sql.= ', f.note_private, f.note_public, f.fk_user_author'; $sql.= ', f.note_private, f.note_public, f.fk_user_author';
@@ -281,7 +281,7 @@ class FactureRec extends CommonInvoice
$this->titre = $obj->titre; $this->titre = $obj->titre;
$this->ref = $obj->titre; $this->ref = $obj->titre;
$this->ref_client = $obj->ref_client; $this->ref_client = $obj->ref_client;
$this->statut = $obj->status; $this->suspended = $obj->suspended;
$this->type = $obj->type; $this->type = $obj->type;
$this->datep = $obj->dp; $this->datep = $obj->dp;
$this->date = $obj->df; $this->date = $obj->df;
@@ -879,6 +879,7 @@ class FactureRec extends CommonInvoice
$facture->brouillon = 1; $facture->brouillon = 1;
$facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
$facture->socid = $facturerec->socid; $facture->socid = $facturerec->socid;
$facture->suspended = 0;
$invoiceidgenerated = $facture->create($user); $invoiceidgenerated = $facture->create($user);
if ($invoiceidgenerated <= 0) if ($invoiceidgenerated <= 0)
@@ -956,57 +957,93 @@ class FactureRec extends CommonInvoice
return $result; return $result;
} }
/**
* Return label of object status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
* @param integer $alreadypaid Not used
* @return string Label
*/
function getLibStatut($mode=0,$alreadypaid=-1)
{
return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, $this->type);
}
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
* @param int $paye Status field paye * @param int $recur Is it a recurring invoice ?
* @param int $status Id status * @param int $status Id status (suspended or not)
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @param int $alreadypaid Not used
* @param int $type Type invoice * @param int $type Type invoice
* @return string Libelle du statut * @return string Libelle du statut
*/ */
function LibStatut($paye,$status,$mode=0,$alreadypaid=-1,$type=0) function LibStatut($recur,$status,$mode=0,$alreadypaid=-1,$type=0)
{ {
global $langs; global $langs;
$langs->load('bills'); $langs->load('bills');
//print "$paye,$status,$mode,$alreadypaid,$type"; //print "$recur,$status,$mode,$alreadypaid,$type";
if ($mode == 0) if ($mode == 0)
{ {
$prefix=''; $prefix='';
if ($type == -1) return $langs->trans('Suspended'); // credit note if ($recur)
else return $langs->trans('Active'); {
if ($status == 1) return $langs->trans('Suspended'); // credit note
else return $langs->trans('Active');
}
else return $langs->trans("Draft");
} }
if ($mode == 1) if ($mode == 1)
{ {
$prefix='Short'; $prefix='Short';
if ($status == -1) return $langs->trans('Suspended'); if ($recur)
else return $langs->trans('Active'); {
if ($status == 1) return $langs->trans('Suspended');
else return $langs->trans('Active');
}
else return $langs->trans("Draft");
} }
if ($mode == 2) if ($mode == 2)
{ {
if ($status == -1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended'); if ($recur)
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active'); {
if ($status == 1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
} }
if ($mode == 3) if ($mode == 3)
{ {
$prefix='Short'; if ($recur)
if ($type == -1) return img_picto($langs->trans('Suspended'),'statut6'); {
else return img_picto($langs->trans('Active'),'statut4'); $prefix='Short';
if ($status == 1) return img_picto($langs->trans('Suspended'),'statut6');
else return img_picto($langs->trans('Active'),'statut4');
}
else return img_picto($langs->trans('Draft'),'statut0');
} }
if ($mode == 4) if ($mode == 4)
{ {
$prefix=''; $prefix='';
if ($type == -1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended'); if ($recur)
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active'); {
if ($type == 1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
} }
if ($mode == 5 || $mode == 6) if ($mode == 5 || $mode == 6)
{ {
$prefix=''; $prefix='';
if ($mode == 5) $prefix='Short'; if ($mode == 5) $prefix='Short';
if ($type == -1) return '<span class="xhideonsmartphone">'.$langs->trans('Suspended').' </span>'.img_picto($langs->trans('Suspended'),'statut6'); if ($recur)
else return '<span class="xhideonsmartphone">'.$langs->trans('Active').' </span>'.img_picto($langs->trans('Active'),'statut4'); {
if ($status == 1) return '<span class="xhideonsmartphone">'.$langs->trans('Suspended').' </span>'.img_picto($langs->trans('Suspended'),'statut6');
else return '<span class="xhideonsmartphone">'.$langs->trans('Active').' </span>'.img_picto($langs->trans('Active'),'statut4');
}
else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');
} }
} }

View File

@@ -121,7 +121,8 @@ $arrayfields=array(
'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1), 'f.nb_gen_done'=>array('label'=>$langs->trans("NbOfGenerationDone"), 'checked'=>1),
'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1), 'f.date_last_gen'=>array('label'=>$langs->trans("DateLastGeneration"), 'checked'=>1),
'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1), 'f.date_when'=>array('label'=>$langs->trans("NextDateToExecution"), 'checked'=>1),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
); );
// Extra fields // Extra fields
@@ -934,6 +935,7 @@ $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
$companystatic = new Societe($db); $companystatic = new Societe($db);
$invoicerectmp = new FactureRec($db);
$now = dol_now(); $now = dol_now();
$tmparray=dol_getdate($now); $tmparray=dol_getdate($now);
@@ -1409,7 +1411,7 @@ else
{ {
if ($object->frequency > 0) if ($object->frequency > 0)
{ {
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
} }
else else
{ {
@@ -1617,7 +1619,7 @@ else
/* /*
* List mode * List mode
*/ */
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,"; $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,"; $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.datec, f.tms"; $sql.= " f.datec, f.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
@@ -1625,7 +1627,7 @@ else
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
} }
$sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " WHERE f.fk_soc = s.rowid";
$sql.= " AND f.entity = ".$conf->entity; $sql.= ' AND f.entity IN ('.getEntity('facture').')';
if (! $user->rights->societe->client->voir && ! $socid) { if (! $user->rights->societe->client->voir && ! $socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
} }
@@ -1837,6 +1839,12 @@ else
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '</td>'; print '</td>';
} }
// Status
if (! empty($arrayfields['status']['checked']))
{
print '<td class="liste_titre" align="center">';
print '</td>';
}
// Action column // Action column
print '<td class="liste_titre" align="middle">'; print '<td class="liste_titre" align="middle">';
$searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1);
@@ -1855,8 +1863,9 @@ else
if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print "</tr>\n"; print "</tr>\n";
@@ -1871,6 +1880,11 @@ else
$companystatic->id=$objp->socid; $companystatic->id=$objp->socid;
$companystatic->name=$objp->name; $companystatic->name=$objp->name;
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (! empty($arrayfields['f.titre']['checked'])) if (! empty($arrayfields['f.titre']['checked']))
@@ -1928,6 +1942,12 @@ else
print dol_print_date($db->jdate($objp->tms),'dayhour'); print dol_print_date($db->jdate($objp->tms),'dayhour');
print '</td>'; print '</td>';
} }
if (! empty($arrayfields['status']['checked']))
{
print '<td align="center">';
print $invoicerectmp->getLibStatut(3,0);
print '</td>';
}
// Action column // Action column
print '<td align="center">'; print '<td align="center">';
if ($user->rights->facture->creer) if ($user->rights->facture->creer)

View File

@@ -1347,6 +1347,11 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2); if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4); else $morehtmlstatus.=$object->getLibStatut(4);
} }
elseif ($object->element == 'facturerec')
{
if ($object->frequency==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4);
}
else { // Generic case else { // Generic case
$tmptxt=$object->getLibStatut(6); $tmptxt=$object->getLibStatut(6);
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);

View File

@@ -38,7 +38,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
-- For 7.0 -- For 7.0
ALTER TABLE llx_facture_rec ADD COLUMN status integer DEFAULT 1; ALTER TABLE llx_facture_rec ADD COLUMN suspended integer DEFAULT 0;
UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL; UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL;

View File

@@ -28,7 +28,7 @@ create table llx_facture_rec
datec datetime, -- date de creation datec datetime, -- date de creation
tms timestamp, -- date creation/modification tms timestamp, -- date creation/modification
status integer DEFAULT 1, -- 1=active, 0=suspended suspended integer DEFAULT 0, -- 1=suspended
amount double(24,8) DEFAULT 0 NOT NULL, amount double(24,8) DEFAULT 0 NOT NULL,
remise real DEFAULT 0, remise real DEFAULT 0,