NEW Template invoices are visible on the customer tab
This commit is contained in:
parent
01664a135d
commit
e7abb39ee2
@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
|
||||
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||
@ -951,6 +952,94 @@ if ($id > 0)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Last invoices templates
|
||||
*/
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$invoicetemplate = new FactureRec($db);
|
||||
|
||||
$sql = 'SELECT f.rowid as id, f.titre as ref, f.amount';
|
||||
$sql.= ', f.total as total_ht';
|
||||
$sql.= ', f.tva as total_tva';
|
||||
$sql.= ', f.total_ttc';
|
||||
$sql.= ', f.datec as dc';
|
||||
$sql.= ', f.status as status';
|
||||
$sql.= ', s.nom, s.rowid as socid';
|
||||
$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.= " AND f.entity = ".$conf->entity;
|
||||
$sql.= ' GROUP BY f.rowid, f.titre, f.amount, f.total, f.tva, f.total_ttc,';
|
||||
$sql.= ' f.datec,';
|
||||
$sql.= ' f.status,';
|
||||
$sql.= ' s.nom, s.rowid';
|
||||
$sql.= " ORDER BY f.datec DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$var=true;
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num > 0)
|
||||
{
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices",($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").' <span class="badge">'.$num.'</span></a></td>';
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
while ($i < $num && $i < $MAXLIST)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowrap">';
|
||||
$invoicetemplate->id = $objp->id;
|
||||
$invoicetemplate->ref = $objp->ref;
|
||||
$invoicetemplate->statut = $objp->status;
|
||||
$invoicetemplate->total_ht = $objp->total_ht;
|
||||
$invoicetemplate->total_tva = $objp->total_tva;
|
||||
$invoicetemplate->total_ttc = $objp->total_ttc;
|
||||
print $invoicetemplate->getNomUrl(1);
|
||||
print '</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 price($objp->total_ht);
|
||||
print '</td>';
|
||||
|
||||
if (! empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES))
|
||||
{
|
||||
print '<td align="right" style="min-width: 60px">';
|
||||
print price($objp->total_ttc);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td align="right" class="nowrap" style="min-width: 60px">';
|
||||
print ($invoicetemplate->LibStatut(0,$invoicetemplate->statut,5,0));
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
if ($num > 0) print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Last invoices
|
||||
*/
|
||||
|
||||
@ -248,7 +248,7 @@ class FactureRec extends CommonInvoice
|
||||
*/
|
||||
function fetch($rowid, $ref='', $ref_ext='', $ref_int='')
|
||||
{
|
||||
$sql = 'SELECT f.rowid, f.entity, f.titre, 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.status, 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.date_lim_reglement as dlr';
|
||||
$sql.= ', f.note_private, f.note_public, f.fk_user_author';
|
||||
@ -281,6 +281,7 @@ class FactureRec extends CommonInvoice
|
||||
$this->titre = $obj->titre;
|
||||
$this->ref = $obj->titre;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->statut = $obj->status;
|
||||
$this->type = $obj->type;
|
||||
$this->datep = $obj->dp;
|
||||
$this->date = $obj->df;
|
||||
@ -297,7 +298,6 @@ class FactureRec extends CommonInvoice
|
||||
$this->close_code = $obj->close_code;
|
||||
$this->close_note = $obj->close_note;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->date_lim_reglement = $this->db->jdate($obj->dlr);
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->mode_reglement_code = $obj->mode_reglement_code;
|
||||
@ -956,6 +956,59 @@ class FactureRec extends CommonInvoice
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $paye Status field paye
|
||||
* @param int $status Id 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 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 $type Type invoice
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
function LibStatut($paye,$status,$mode=0,$alreadypaid=-1,$type=0)
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('bills');
|
||||
|
||||
//print "$paye,$status,$mode,$alreadypaid,$type";
|
||||
if ($mode == 0)
|
||||
{
|
||||
$prefix='';
|
||||
if ($type == -1) return $langs->trans('Suspended'); // credit note
|
||||
else return $langs->trans('Active');
|
||||
}
|
||||
if ($mode == 1)
|
||||
{
|
||||
$prefix='Short';
|
||||
if ($status == -1) return $langs->trans('Suspended');
|
||||
else return $langs->trans('Active');
|
||||
}
|
||||
if ($mode == 2)
|
||||
{
|
||||
if ($status == -1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
|
||||
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
|
||||
}
|
||||
if ($mode == 3)
|
||||
{
|
||||
$prefix='Short';
|
||||
if ($type == -1) return img_picto($langs->trans('Suspended'),'statut6');
|
||||
else return img_picto($langs->trans('Active'),'statut4');
|
||||
}
|
||||
if ($mode == 4)
|
||||
{
|
||||
$prefix='';
|
||||
if ($type == -1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
|
||||
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
|
||||
}
|
||||
if ($mode == 5 || $mode == 6)
|
||||
{
|
||||
$prefix='';
|
||||
if ($mode == 5) $prefix='Short';
|
||||
if ($type == -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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise an instance with random values.
|
||||
@ -1309,7 +1362,7 @@ class FactureLigneRec extends CommonInvoiceLine
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
||||
$sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
|
||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' l.rang, l.special_code,';
|
||||
|
||||
@ -2956,6 +2956,8 @@ abstract class CommonObject
|
||||
*/
|
||||
function isObjectUsed($id=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($id)) $id=$this->id;
|
||||
|
||||
// Check parameters
|
||||
@ -2965,10 +2967,19 @@ abstract class CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$arraytoscan = $this->childtables;
|
||||
// For backward compatibility, we check if array is old format array('table1', 'table2', ...)
|
||||
$tmparray=array_keys($this->childtables);
|
||||
if (is_numeric($tmparray[0]))
|
||||
{
|
||||
$arraytoscan = array_flip($this->childtables);
|
||||
}
|
||||
|
||||
// Test if child exists
|
||||
$haschild=0;
|
||||
foreach($this->childtables as $table)
|
||||
foreach($arraytoscan as $table => $elementname)
|
||||
{
|
||||
//print $id.'-'.$table.'-'.$elementname.'<br>';
|
||||
// Check if third party can be deleted
|
||||
$sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table;
|
||||
$sql.= " WHERE ".$this->fk_element." = ".$id;
|
||||
@ -2976,19 +2987,24 @@ abstract class CommonObject
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->db->fetch_object($resql);
|
||||
$haschild+=$obj->nb;
|
||||
//print 'Found into table '.$table;
|
||||
if ($haschild) break; // We found at least on, we stop here
|
||||
if ($obj->nb > 0)
|
||||
{
|
||||
$langs->load("errors");
|
||||
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
|
||||
$haschild += $obj->nb;
|
||||
$this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
|
||||
break; // We found at least one, we stop here
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
$this->errors[]=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ($haschild > 0)
|
||||
{
|
||||
$this->error="ErrorRecordHasChildren";
|
||||
$this->errors[]="ErrorRecordHasChildren";
|
||||
return $haschild;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
@ -35,6 +35,11 @@ ALTER TABLE llx_product_price ADD COLUMN multicurrency_price_ttc double(24,8) DE
|
||||
ALTER TABLE llx_website_page ADD COLUMN fk_user_create integer;
|
||||
ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
|
||||
|
||||
|
||||
-- For 7.0
|
||||
|
||||
ALTER TABLE llx_facture_rec ADD COLUMN status integer DEFAULT 1;
|
||||
|
||||
UPDATE llx_c_email_templates SET position = 0 WHERE position IS NULL;
|
||||
|
||||
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VENTES', 'Income of products/services', 'Exemple: 7xxxxx', 0, 0, '', '10', 1, 1);
|
||||
|
||||
@ -28,6 +28,8 @@ create table llx_facture_rec
|
||||
datec datetime, -- date de creation
|
||||
tms timestamp, -- date creation/modification
|
||||
|
||||
status integer DEFAULT 1, -- 1=active, 0=suspended
|
||||
|
||||
amount double(24,8) DEFAULT 0 NOT NULL,
|
||||
remise real DEFAULT 0,
|
||||
remise_percent real DEFAULT 0,
|
||||
|
||||
@ -155,9 +155,13 @@ FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) q
|
||||
NotARecurringInvoiceTemplate=Not a recurring template invoice
|
||||
NewBill=New invoice
|
||||
LastBills=Latest %s invoices
|
||||
LatestTemplateInvoices=Latest %s template invoices
|
||||
LatestCustomerTemplateInvoices=Latest %s customer template invoices
|
||||
LatestSupplierTemplateInvoices=Latest %s supplier template invoices
|
||||
LastCustomersBills=Latest %s customer invoices
|
||||
LastSuppliersBills=Latest %s supplier invoices
|
||||
AllBills=All invoices
|
||||
AllCustomerTemplateInvoices=All template invoices
|
||||
OtherBills=Other invoices
|
||||
DraftBills=Draft invoices
|
||||
CustomersDraftInvoices=Customer draft invoices
|
||||
|
||||
@ -75,6 +75,7 @@ ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not s
|
||||
ErrorRefAlreadyExists=Ref used for creation already exists.
|
||||
ErrorPleaseTypeBankTransactionReportName=Please type bank statement name where entry is reported (Format YYYYMM or YYYYMMDD)
|
||||
ErrorRecordHasChildren=Failed to delete record since it has some childs.
|
||||
ErrorRecordHasAtLeastOneChildOfType=Object has at least one child of type %s
|
||||
ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into other object.
|
||||
ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display.
|
||||
ErrorPasswordsMustMatch=Both typed passwords must match each other
|
||||
|
||||
@ -1977,7 +1977,7 @@ else
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200);
|
||||
}
|
||||
|
||||
dol_htmloutput_errors($error,$errors);
|
||||
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
@ -43,9 +43,11 @@ class Societe extends CommonObject
|
||||
public $element='societe';
|
||||
public $table_element = 'societe';
|
||||
public $fk_element='fk_soc';
|
||||
protected $childtables=array("supplier_proposal","propal","commande","facture","facture_rec","contrat","fichinter","facture_fourn","commande_fournisseur","projet","expedition","prelevement_lignes"); // To test if we can delete object
|
||||
protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object
|
||||
protected $childtablesoncascade=array("llx_societe_prices", "llx_societe_log", "llx_societe_address", "llx_product_fournisseur_price", "llx_product_customer_price_log", "llx_product_customer_price", "socpeople", "adherent", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "llx_categorie", "llx_notify", "llx_notfy_def");
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
* @var int
|
||||
*/
|
||||
@ -1424,11 +1426,11 @@ class Societe extends CommonObject
|
||||
// Fill $toute_categs array with an array of (type => array of ("Categorie" instance))
|
||||
if ($this->client || $this->prospect)
|
||||
{
|
||||
$toute_categs ['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER);
|
||||
$toute_categs['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER);
|
||||
}
|
||||
if ($this->fournisseur)
|
||||
{
|
||||
$toute_categs ['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER);
|
||||
$toute_categs['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER);
|
||||
}
|
||||
|
||||
// Remove each "Categorie"
|
||||
@ -1441,78 +1443,19 @@ class Societe extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
// Remove contacts
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Update link in member table
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
|
||||
$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error .= $this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::delete erreur -1 ".$this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ban
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove societe_remise
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise";
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove societe_remise_except
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except";
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove associated users
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux";
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
foreach ($this->childtablesoncascade as $tabletodelete)
|
||||
{
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete;
|
||||
$sql.= " WHERE fk_soc = " . $id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Removed extrafields
|
||||
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
|
||||
@ -1530,11 +1473,10 @@ class Societe extends CommonObject
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql.= " WHERE rowid = " . $id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user