'.$langs->trans('BankAccount').' ';
@@ -3907,7 +3926,7 @@ elseif ($id > 0 || !empty($ref))
$morehtmlref = '';
// Ref invoice
- if ($object->status == $object::STATUS_DRAFT && ! $mysoc->isInEEC() && ! empty($conf->global->INVOICE_ALLOW_FREE_REF)) {
+ if ($object->status == $object::STATUS_DRAFT && !$mysoc->isInEEC() && !empty($conf->global->INVOICE_ALLOW_FREE_REF)) {
$morehtmlref .= $form->editfieldkey("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Ref", 'ref', $object->ref, $object, $usercancreate, 'string', '', null, null, '', 1);
$morehtmlref .= '
';
@@ -5099,7 +5118,7 @@ elseif ($id > 0 || !empty($ref))
}
// For credit note
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate
- && (! empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
+ && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
) {
print '
id.'&action=converttoreduc" title="'.dol_escape_htmltag($langs->trans("ConfirmConvertToReduc2")).'">'.$langs->trans('ConvertToReduc').' ';
}
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 7c7437bfb8e..e68966f4663 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -242,10 +242,10 @@ class Invoices extends DolibarrApi
* @url POST /createfromorder/{orderid}
*
* @return int
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function createInvoiceFromOrder($orderid)
{
@@ -318,10 +318,9 @@ class Invoices extends DolibarrApi
*
* @return array
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404 Invoice not found
*/
public function putLine($id, $lineid, $request_data = null)
{
@@ -383,8 +382,9 @@ class Invoices extends DolibarrApi
* @url POST {id}/contact/{contactid}/{type}
*
* @return int
- * @throws 401
- * @throws 404
+ *
+ * @throws RestException 401
+ * @throws RestException 404
*/
public function postContact($id, $contactid, $type)
{
@@ -424,9 +424,10 @@ class Invoices extends DolibarrApi
* @url DELETE {id}/contact/{rowid}
*
* @return array
- * @throws 401
- * @throws 404
- * @throws 500
+ *
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*/
public function deleteContact($id, $rowid)
{
@@ -463,10 +464,10 @@ class Invoices extends DolibarrApi
*
* @return array
*
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function deleteLine($id, $lineid)
{
@@ -591,10 +592,9 @@ class Invoices extends DolibarrApi
*
* @return int
*
- * @throws 200
- * @throws 401
- * @throws 404
- * @throws 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 400
*/
public function postLine($id, $request_data = null)
{
@@ -673,11 +673,10 @@ class Invoices extends DolibarrApi
*
* @return array
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*
*/
public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0)
@@ -723,11 +722,10 @@ class Invoices extends DolibarrApi
*
* @return array
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*
*/
public function settodraft($id, $idwarehouse = -1)
@@ -827,11 +825,10 @@ class Invoices extends DolibarrApi
*
* @return array An invoice object
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*/
public function settopaid($id, $close_code = '', $close_note = '')
{
@@ -878,11 +875,10 @@ class Invoices extends DolibarrApi
*
* @return array An invoice object
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*/
public function settounpaid($id)
{
@@ -927,11 +923,10 @@ class Invoices extends DolibarrApi
*
* @return array An invoice object
*
- * @throws 200
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*/
public function markAsCreditAvailable($id)
{
@@ -1103,10 +1098,10 @@ class Invoices extends DolibarrApi
* @url POST {id}/usediscount/{discountid}
*
* @return int
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function useDiscount($id, $discountid)
{
@@ -1149,10 +1144,10 @@ class Invoices extends DolibarrApi
* @url POST {id}/usecreditnote/{discountid}
*
* @return int
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function useCreditNote($id, $discountid)
{
@@ -1194,10 +1189,11 @@ class Invoices extends DolibarrApi
* @url GET {id}/payments
*
* @return array
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ *
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function getPayments($id)
{
@@ -1243,9 +1239,9 @@ class Invoices extends DolibarrApi
* @url POST {id}/payments
*
* @return int Payment ID
- * @throws 400
- * @throws 401
- * @throws 404
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
*/
public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '')
{
@@ -1362,10 +1358,10 @@ class Invoices extends DolibarrApi
* @url POST /paymentsdistributed
*
* @return int Payment ID
- * @throws 400
- * @throws 401
- * @throws 403
- * @throws 404
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 403
+ * @throws RestException 404
*/
public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '')
{
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 5480142ec78..fdffc320880 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -71,7 +71,6 @@ class FactureRec extends CommonInvoice
public $number;
public $date;
- public $amount;
public $remise;
public $tva;
public $total;
@@ -93,6 +92,81 @@ class FactureRec extends CommonInvoice
public $suspended; // status
+ /**
+ * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'enabled' is a condition when the field must be managed.
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'css' is the CSS style to use on field. For example: 'maxwidth200'
+ * 'help' is a string visible as a tooltip on field
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'visible'=>-1, 'position'=>15),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
+ 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
+ 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
+ //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
+ 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
+ //'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
+ //'remise_absolue' =>array('type'=>'double', 'label'=>'Remise absolue', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
+ 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>55, 'isameasure'=>1),
+ 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1),
+ 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1),
+ 'total' =>array('type'=>'double(24,8)', 'label'=>'Total', 'enabled'=>1, 'visible'=>-1, 'position'=>70, 'isameasure'=>1),
+ 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>75, 'isameasure'=>1),
+ 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
+ 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
+ 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Fk cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
+ 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'Fk mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
+ 'date_lim_reglement' =>array('type'=>'date', 'label'=>'Date lim reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>100),
+ 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105),
+ 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110),
+ 'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
+ 'last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
+ 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
+ 'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130),
+ 'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135),
+ 'nb_gen_done' =>array('type'=>'integer', 'label'=>'Nb gen done', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
+ 'nb_gen_max' =>array('type'=>'integer', 'label'=>'Nb gen max', 'enabled'=>1, 'visible'=>-1, 'position'=>145),
+ 'frequency' =>array('type'=>'integer', 'label'=>'Frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
+ 'usenewprice' =>array('type'=>'integer', 'label'=>'UseNewPrice', 'enabled'=>1, 'visible'=>0, 'position'=>155),
+ 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1),
+ 'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
+ 'generate_pdf' =>array('type'=>'integer', 'label'=>'Generate pdf', 'enabled'=>1, 'visible'=>-1, 'position'=>170),
+ 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>175),
+ 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>180),
+ 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
+ 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency tx', 'enabled'=>1, 'visible'=>-1, 'position'=>190, 'isameasure'=>1),
+ 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>1, 'visible'=>-1, 'position'=>195, 'isameasure'=>1),
+ 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>1, 'visible'=>-1, 'position'=>200, 'isameasure'=>1),
+ 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>1, 'visible'=>-1, 'position'=>205, 'isameasure'=>1),
+ 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>210),
+ 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>215),
+ 'suspended' =>array('type'=>'integer', 'label'=>'Suspended', 'enabled'=>1, 'visible'=>-1, 'position'=>225),
+ );
+ // END MODULEBUILDER PROPERTIES
+
const STATUS_NOTSUSPENDED = 0;
const STATUS_SUSPENDED = 1;
@@ -377,7 +451,7 @@ class FactureRec extends CommonInvoice
*/
public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '')
{
- $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc';
+ $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, 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';
@@ -419,7 +493,6 @@ class FactureRec extends CommonInvoice
$this->type = $obj->type;
$this->datep = $obj->dp;
$this->date = $obj->df;
- $this->amount = $obj->amount;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->remise = $obj->remise;
@@ -1602,7 +1675,7 @@ class FactureRec extends CommonInvoice
$xnbp++;
}
- $this->usenewprice = 1;
+ $this->usenewprice = 0;
}
/**
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index d4a7efd3cf4..325b72a455d 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -221,6 +221,102 @@ class Facture extends CommonInvoice
*/
public $retained_warranty_fk_cond_reglement;
+
+ /**
+ * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'enabled' is a condition when the field must be managed.
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'css' is the CSS style to use on field. For example: 'maxwidth200'
+ * 'help' is a string visible as a tooltip on field
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields = array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
+ 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>25),
+ 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30),
+ 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
+ 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
+ 'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
+ 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>50),
+ 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55),
+ 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>60),
+ 'date_valid' =>array('type'=>'date', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
+ 'date_closing' =>array('type'=>'datetime', 'label'=>'Date closing', 'enabled'=>1, 'visible'=>-1, 'position'=>70),
+ 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>75),
+ 'paye' =>array('type'=>'smallint(6)', 'label'=>'InvoicePaidCompletely', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>80),
+ //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>85),
+ 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
+ 'remise_absolue' =>array('type'=>'double', 'label'=>'Remise absolue', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
+ 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100),
+ 'close_code' =>array('type'=>'varchar(16)', 'label'=>'EarlyClosingReason', 'enabled'=>1, 'visible'=>-1, 'position'=>105),
+ 'close_note' =>array('type'=>'varchar(128)', 'label'=>'EarlyClosingComment', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
+ 'tva' =>array('type'=>'double(24,8)', 'label'=>'TotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1),
+ 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1),
+ 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
+ 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
+ 'total' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
+ 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
+ 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Paid', 3=>'Abandonned')),
+ 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
+ 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>155),
+ 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>160),
+ 'fk_user_closing' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
+ 'fk_facture_source' =>array('type'=>'integer', 'label'=>'SourceInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>170),
+ 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>175),
+ 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>180),
+ 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'CurrencyCode', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
+ 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>190),
+ 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
+ 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateDue', 'enabled'=>1, 'visible'=>-1, 'position'=>200),
+ 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>205),
+ 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>210),
+ 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>215),
+ 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>225),
+ 'situation_cycle_ref' =>array('type'=>'smallint(6)', 'label'=>'Situation cycle ref', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>230),
+ 'situation_counter' =>array('type'=>'smallint(6)', 'label'=>'Situation counter', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>235),
+ 'situation_final' =>array('type'=>'smallint(6)', 'label'=>'Situation final', 'enabled'=>'empty($conf->global->INVOICE_USE_SITUATION) ? 0 : 1', 'visible'=>-1, 'position'=>240),
+ 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245),
+ 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250),
+ 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255),
+ 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermsCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260),
+ 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermsLocation', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265),
+ 'date_pointoftax' =>array('type'=>'date', 'label'=>'DatePointOfTax', 'enabled'=>'$conf->global->INVOICE_POINTOFTAX_DATE', 'visible'=>-1, 'position'=>270),
+ 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'MulticurrencyID', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>275),
+ 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCode', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>280),
+ 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>285),
+ 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>290),
+ 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>295),
+ 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>300),
+ 'fk_fac_rec_source' =>array('type'=>'integer', 'label'=>'RecurringInvoiceSource', 'enabled'=>1, 'visible'=>-1, 'position'=>305),
+ 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>310),
+ 'module_source' =>array('type'=>'varchar(32)', 'label'=>'POSModule', 'enabled'=>1, 'visible'=>-1, 'position'=>315),
+ 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>320),
+ 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>220),
+ );
+ // END MODULEBUILDER PROPERTIES
+
/**
* Standard invoice
*/
@@ -284,6 +380,7 @@ class Facture extends CommonInvoice
const CLOSECODE_ABANDONED = 'abandon'; // Abandonned - other
const CLOSECODE_REPLACED = 'replaced'; // Closed after doing a replacement invoice
+
/**
* Constructor
*
@@ -1156,6 +1253,14 @@ class Facture extends CommonInvoice
$line->date_start = $object->lines[$i]->date_start;
$line->date_end = $object->lines[$i]->date_end;
+ // Multicurrency
+ $line->fk_multicurrency = $object->lines[$i]->fk_multicurrency;
+ $line->multicurrency_code = $object->lines[$i]->multicurrency_code;
+ $line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice;
+ $line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht;
+ $line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva;
+ $line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc;
+
$line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);
$line->pa_ht = $marginInfos[0];
@@ -1170,12 +1275,13 @@ class Facture extends CommonInvoice
$this->socid = $object->socid;
$this->fk_project = $object->fk_project;
+ $this->fk_account = $object->fk_account;
$this->cond_reglement_id = $object->cond_reglement_id;
$this->mode_reglement_id = $object->mode_reglement_id;
$this->availability_id = $object->availability_id;
$this->demand_reason_id = $object->demand_reason_id;
$this->date_livraison = $object->date_livraison;
- $this->fk_delivery_address = $object->fk_delivery_address; // deprecated
+ $this->fk_delivery_address = $object->fk_delivery_address; // deprecated
$this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client;
@@ -1339,7 +1445,7 @@ class Facture extends CommonInvoice
}
/**
- * Get object and lines from database
+ * Get object from database. Get also lines.
*
* @param int $rowid Id of object to load
* @param string $ref Reference of invoice
@@ -1354,7 +1460,7 @@ class Facture extends CommonInvoice
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
- $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount';
+ $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc';
$sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
$sql .= ', f.remise_percent, f.remise_absolue, f.remise';
$sql .= ', f.datef as df, f.date_pointoftax';
@@ -1417,10 +1523,16 @@ class Facture extends CommonInvoice
$this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc;
$this->revenuestamp = $obj->revenuestamp;
- $this->paye = $obj->paye;
+ $this->paye = $obj->paye;
$this->close_code = $obj->close_code;
$this->close_note = $obj->close_note;
- $this->socid = $obj->fk_soc;
+
+ $this->socid = $obj->fk_soc;
+ $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
+
+ $this->fk_project = $obj->fk_project;
+ $this->project = null; // Clear if another value was already set by fetch_projet
+
$this->statut = $obj->fk_statut;
$this->date_lim_reglement = $this->db->jdate($obj->dlr);
$this->mode_reglement_id = $obj->fk_mode_reglement;
@@ -1431,7 +1543,6 @@ class Facture extends CommonInvoice
$this->cond_reglement = $obj->cond_reglement_libelle;
$this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
$this->fk_account = ($obj->fk_account > 0) ? $obj->fk_account : null;
- $this->fk_project = $obj->fk_project;
$this->fk_facture_source = $obj->fk_facture_source;
$this->fk_fac_rec_source = $obj->fk_fac_rec_source;
$this->note = $obj->note_private; // deprecated
@@ -1477,10 +1588,7 @@ class Facture extends CommonInvoice
// fetch optionals attributes and labels
$this->fetch_optionals();
- /*
- * Lines
- */
-
+ // Lines
$this->lines = array();
$result = $this->fetch_lines();
@@ -1591,7 +1699,7 @@ class Facture extends CommonInvoice
$line->special_code = $objp->special_code;
$line->fk_parent_line = $objp->fk_parent_line;
$line->situation_percent = $objp->situation_percent;
- $line->fk_prev_id = $objp->fk_prev_id;
+ $line->fk_prev_id = $objp->fk_prev_id;
$line->fk_unit = $objp->fk_unit;
// Accountancy
@@ -2035,7 +2143,7 @@ class Facture extends CommonInvoice
}
}
- // If we decrement stock on invoice validation, we increment
+ // If we decrease stock on invoice validation, we increase back if a warehouse id was provided
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1)
{
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
@@ -2646,7 +2754,7 @@ class Facture extends CommonInvoice
$this->oldcopy = clone $this;
}
- // Si on decremente le produit principal et ses composants a la validation de facture, on réincrement
+ // If we decrease stock on invoice validation, we increase back
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL))
{
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
@@ -3134,7 +3242,7 @@ class Facture extends CommonInvoice
$this->line->rang = $rangmax + 1;
}
- $this->line->id = $rowid;
+ $this->line->id = $rowid;
$this->line->rowid = $rowid;
$this->line->label = $label;
$this->line->desc = $desc;
@@ -3175,7 +3283,7 @@ class Facture extends CommonInvoice
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
- foreach($array_options as $key => $value) {
+ foreach ($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
}
@@ -4005,7 +4113,7 @@ class Facture extends CommonInvoice
if ($generic_facture->hasDelay()) {
$response->nbtodolate++;
- $response->url_late=DOL_URL_ROOT.'/compta/facture/list.php?search_option=late&mainmenu=billing&leftmenu=customers_bills';
+ $response->url_late = DOL_URL_ROOT.'/compta/facture/list.php?search_option=late&mainmenu=billing&leftmenu=customers_bills';
}
}
@@ -4482,18 +4590,18 @@ class Facture extends CommonInvoice
if ($this->statut != Facture::STATUS_VALIDATED) return false;
$hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay);
- if($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit))
+ if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit))
{
$totalpaye = $this->getSommePaiement();
$totalpaye = floatval($totalpaye);
$RetainedWarrantyAmount = $this->getRetainedWarrantyAmount();
- if($totalpaye >= 0 && $RetainedWarrantyAmount>= 0)
+ if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0)
{
- if( ($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay) )
+ if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay))
{
$hasDelay = 1;
}
- elseif($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay) )
+ elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay))
{
$hasDelay = 1;
}
@@ -4558,8 +4666,8 @@ class Facture extends CommonInvoice
$retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100;
}
- if ($rounding < 0){
- $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
+ if ($rounding < 0) {
+ $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
return round($retainedWarrantyAmount, 2);
}
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 6fe15241c5a..b32d82a08cb 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -13,6 +13,7 @@
* Copyright (C) 2015-2016 Ferran Marcet
* Copyright (C) 2017 Josep Lluís Amador
* Copyright (C) 2018 Charlene Benke
+ * Copyright (C) 2019 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -98,12 +99,10 @@ $search_country = GETPOST("search_country", 'int');
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
$search_user = GETPOST('search_user', 'int');
$search_sale = GETPOST('search_sale', 'int');
-$search_day = GETPOST('search_day', 'int');
-$search_month = GETPOST('search_month', 'int');
-$search_year = GETPOST('search_year', 'int');
-$search_day_lim = GETPOST('search_day_lim', 'int');
-$search_month_lim = GETPOST('search_month_lim', 'int');
-$search_year_lim = GETPOST('search_year_lim', 'int');
+$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
+$search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
+$search_datelimit_start = dol_mktime(0, 0, 0, GETPOST('search_datelimit_startmonth', 'int'), GETPOST('search_datelimit_startday', 'int'), GETPOST('search_datelimit_startyear', 'int'));
+$search_datelimit_end = dol_mktime(23, 59, 59, GETPOST('search_datelimit_endmonth', 'int'), GETPOST('search_datelimit_endday', 'int'), GETPOST('search_datelimit_endyear', 'int'));
$search_categ_cus = trim(GETPOST("search_categ_cus", 'int'));
$search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha');
@@ -248,14 +247,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_type = '';
$search_country = '';
$search_type_thirdparty = '';
- $search_day = '';
- $search_year = '';
- $search_month = '';
+ $search_date_start = '';
+ $search_date_end = '';
+ $search_datelimit_start = '';
+ $search_datelimit_end = '';
$option = '';
$filter = '';
- $search_day_lim = '';
- $search_year_lim = '';
- $search_month_lim = '';
$toselect = '';
$search_array_options = array();
$search_categ_cus = 0;
@@ -478,12 +475,15 @@ if ($search_status != '-1' && $search_status != '')
$sql .= " AND f.fk_statut IN (".$db->escape($search_status).")"; // When search_status is '1,2' for example
}
}
+
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms);
if ($search_module_source) $sql .= natural_search("f.module_source", $search_module_source);
if ($search_pos_source) $sql .= natural_search("f.pos_source", $search_pos_source);
-$sql .= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year);
-$sql .= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim);
+if ($search_date_start) $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
+if ($search_date_end) $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
+if ($search_datelimit_start) $sql .= " AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start)."'";
+if ($search_datelimit_end) $sql .= " AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end)."'";
if ($option == 'late') $sql .= " AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".(int) $search_sale;
if ($search_user > 0)
@@ -571,12 +571,10 @@ if ($resql)
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($sall) $param .= '&sall='.urlencode($sall);
- if ($search_day) $param .= '&search_day='.urlencode($search_day);
- if ($search_month) $param .= '&search_month='.urlencode($search_month);
- if ($search_year) $param .= '&search_year='.urlencode($search_year);
- if ($search_day_lim) $param .= '&search_day_lim='.urlencode($search_day_lim);
- if ($search_month_lim) $param .= '&search_month_lim='.urlencode($search_month_lim);
- if ($search_year_lim) $param .= '&search_year_lim='.urlencode($search_year_lim);
+ if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start);
+ if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end);
+ if ($search_datelimit_start) $param .= '&search_datelimit_start='.urlencode($search_datelimit_start);
+ if ($search_datelimit_end) $param .= '&search_datelimit_end='.urlencode($search_datelimit_end);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_refcustomer) $param .= '&search_refcustomer='.urlencode($search_refcustomer);
if ($search_project_ref) $param .= '&search_project_ref='.urlencode($search_project_ref);
@@ -752,20 +750,29 @@ if ($resql)
// Date invoice
if (!empty($arrayfields['f.date']['checked']))
{
- print '';
- if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
+ print ' ';
+ print '';
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1);
+ print '
';
+ print '';
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1);
+ print '
';
print ' ';
}
// Date due
if (!empty($arrayfields['f.date_lim_reglement']['checked']))
{
- print '';
- if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
- print ' '.$langs->trans("Alert");
+ print ' ';
+ print '';
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
+ print '
';
+ print '';
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1);
+ print '
';
print ' ';
}
// Project ref
@@ -778,7 +785,7 @@ if ($resql)
{
print ' ';
}
- // Thirpdarty
+ // Thirdparty
if (!empty($arrayfields['s.nom']['checked']))
{
print ' ';
@@ -1055,7 +1062,6 @@ if ($resql)
{
print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1);
}
- print empty($obj->increment) ? '' : ' ('.$obj->increment.')';
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref);
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index b00ef1d9a0a..3853847c363 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -75,6 +75,8 @@ if ($facid > 0)
// Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('paiementcard', 'globalcard'));
+$formquestion = array();
+
/*
* Actions
@@ -264,8 +266,8 @@ if (empty($reshook))
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->note_private = GETPOST('comment', 'alpha');
- $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
- $paiement->note = $paiement->note_private; // For bacward compatibility
+ $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
+ $paiement->note = $paiement->note_private; // For bacward compatibility
if (!$error)
{
@@ -863,7 +865,7 @@ if (!GETPOST('action', 'aZ09'))
if (!$sortorder) $sortorder = 'DESC';
if (!$sortfield) $sortfield = 'p.datep';
- $sql = 'SELECT p.datep as dp, p.amount, f.amount as fa_amount, f.ref';
+ $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql .= ', '.MAIN_DB_PREFIX.'facture as f';
@@ -886,10 +888,10 @@ if (!GETPOST('action', 'aZ09'))
print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
print '';
print '';
- print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'ref', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'dp', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'libelle', '', '', '', $sortfield, $sortorder);
- print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'fa_amount', '', '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
+ print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print " \n";
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 71c8596e00a..9b0ee645fc7 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -29,8 +29,8 @@
* \ingroup facture
* \brief File of class to manage payments of customers invoices
*/
-require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
-require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
/**
@@ -41,12 +41,12 @@ class Paiement extends CommonObject
/**
* @var string ID to identify managed object
*/
- public $element='payment';
+ public $element = 'payment';
/**
* @var string Name of table without prefix where object is stored
*/
- public $table_element='paiement';
+ public $table_element = 'paiement';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@@ -68,12 +68,12 @@ class Paiement extends CommonObject
*/
public $montant;
- public $amount; // Total amount of payment
- public $amounts=array(); // Array of amounts
- public $multicurrency_amounts=array(); // Array of amounts
+ public $amount; // Total amount of payment
+ public $amounts = array(); // Array of amounts
+ public $multicurrency_amounts = array(); // Array of amounts
public $author;
- public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement
- public $paiementcode; // Code of payment.
+ public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement
+ public $paiementcode; // Code of payment.
/**
* @var string type libelle
@@ -136,7 +136,7 @@ class Paiement extends CommonObject
/**
* @var int payment id
*/
- public $fk_paiement; // Type of payment
+ public $fk_paiement; // Type of payment
/**
@@ -160,18 +160,18 @@ class Paiement extends CommonObject
public function fetch($id, $ref = '', $fk_bank = '')
{
$sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,';
- $sql.= ' c.code as type_code, c.libelle as type_label,';
- $sql.= ' p.num_paiement as num_payment, p.note,';
- $sql.= ' b.fk_account';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
- $sql.= ' WHERE p.entity IN (' . getEntity('invoice').')';
+ $sql .= ' c.code as type_code, c.libelle as type_label,';
+ $sql .= ' p.num_paiement as num_payment, p.note,';
+ $sql .= ' b.fk_account';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
+ $sql .= ' WHERE p.entity IN ('.getEntity('invoice').')';
if ($id > 0)
- $sql.= ' AND p.rowid = '.$id;
+ $sql .= ' AND p.rowid = '.$id;
elseif ($ref)
- $sql.= " AND p.ref = '".$ref."'";
+ $sql .= " AND p.ref = '".$ref."'";
elseif ($fk_bank)
- $sql.= ' AND p.fk_bank = '.$fk_bank;
+ $sql .= ' AND p.fk_bank = '.$fk_bank;
$resql = $this->db->query($sql);
if ($resql)
@@ -180,15 +180,15 @@ class Paiement extends CommonObject
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
- $this->ref = $obj->ref?$obj->ref:$obj->rowid;
+ $this->ref = $obj->ref ? $obj->ref : $obj->rowid;
$this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp);
- $this->num_paiement = $obj->num_payment; // deprecated
+ $this->num_paiement = $obj->num_payment; // deprecated
$this->num_payment = $obj->num_payment;
- $this->montant = $obj->amount; // deprecated
+ $this->montant = $obj->amount; // deprecated
$this->amount = $obj->amount;
$this->note = $obj->note;
- $this->type_label = $obj->type_label;
+ $this->type_label = $obj->type_label;
$this->type_code = $obj->type_code;
$this->statut = $obj->statut;
$this->ext_payment_id = $obj->ext_payment_id;
@@ -231,7 +231,7 @@ class Paiement extends CommonObject
$error = 0;
$way = $this->getWay();
- $now=dol_now();
+ $now = dol_now();
// Clean parameters
$totalamount = 0;
@@ -258,7 +258,7 @@ class Paiement extends CommonObject
$newvalue = price2num($value, 'MT');
$amounts[$key] = $newvalue;
$totalamount += $newvalue;
- if (! empty($newvalue)) $atleastonepaymentnotnull++;
+ if (!empty($newvalue)) $atleastonepaymentnotnull++;
}
$totalamount = price2num($totalamount);
@@ -267,14 +267,16 @@ class Paiement extends CommonObject
// Check parameters
if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays
{
- $this->errors[]='TotalAmountEmpty';
- $this->error='TotalAmountEmpty';
+ $this->errors[] = 'TotalAmountEmpty';
+ $this->error = 'TotalAmountEmpty';
return -1;
}
- $this->db->begin();
+ dol_syslog(get_class($this)."::create insert paiement", LOG_DEBUG);
- $this->ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
+ $this->db->begin();
+
+ $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
if ($way == 'dolibarr')
{
@@ -287,13 +289,12 @@ class Paiement extends CommonObject
$mtotal = $totalamount;
}
- $num_payment = ($this->num_payment?$this->num_payment:$this->num_paiement);
- $note = ($this->note_public?$this->note_public:$this->note);
+ $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
+ $note = ($this->note_public ? $this->note_public : $this->note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)";
- $sql.= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id?"'".$this->db->escape($this->ext_payment_id)."'":"null").", ".($this->ext_payment_site?"'".$this->db->escape($this->ext_payment_site)."'":"null").", ".$user->id.")";
+ $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.")";
- dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@@ -307,48 +308,26 @@ class Paiement extends CommonObject
{
$amount = price2num($amount);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)';
- $sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')';
+ $sql .= ' VALUES ('.$facid.', '.$this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')';
- dol_syslog(get_class($this).'::Create Amount line '.$key.' insert paiement_facture', LOG_DEBUG);
- $resql=$this->db->query($sql);
+ dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG);
+ $resql = $this->db->query($sql);
if ($resql)
{
- $invoice=new Facture($this->db);
+ $invoice = new Facture($this->db);
$invoice->fetch($facid);
// If we want to closed payed invoices
if ($closepaidinvoices)
{
$paiement = $invoice->getSommePaiement();
- $creditnotes=$invoice->getSumCreditNotesUsed();
- $deposits=$invoice->getSumDepositsUsed();
- $alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT');
- $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
+ $creditnotes = $invoice->getSumCreditNotesUsed();
+ $deposits = $invoice->getSumDepositsUsed();
+ $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
+ $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
- /* Why this ? We can remove i think.
- // If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing.
- $mustwait=0;
- $sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande";
- $sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0";
- ...
-
- $listofpayments=$invoice->getListOfPayments();
- foreach($listofpayments as $paym)
- {
- // This payment on invoice $invoice might be the one we record or another one
- if ($paym['type']=='PRE')
- {
- if (! empty($conf->prelevement->enabled))
- {
- // if not, $mustwait++; // This will disable automatic close on invoice to allow to process
-
- }
- }
- }
- */
-
//Invoice types that are eligible for changing status to paid
$affected_types = array(
Facture::TYPE_STANDARD,
@@ -416,12 +395,12 @@ class Paiement extends CommonObject
}
// Set invoice to paid
- if (! $error)
+ if (!$error)
{
- $result=$invoice->set_paid($user, '', '');
- if ($result<0)
+ $result = $invoice->set_paid($user, '', '');
+ if ($result < 0)
{
- $this->error=$invoice->error;
+ $this->error = $invoice->error;
$error++;
}
}
@@ -431,10 +410,15 @@ class Paiement extends CommonObject
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $newlang='';
+ dol_syslog(get_class($this).'::create Regenerate the document after inserting payment for thirdparty default_lang='.(is_object($invoice->thirdparty) ? $invoice->thirdparty->default_lang : 'null'), LOG_DEBUG);
+
+ $newlang = '';
$outputlangs = $langs;
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
- if (! empty($newlang)) {
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $invoice->fetch_thirdparty();
+ $newlang = $invoice->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
@@ -448,7 +432,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
$error++;
}
}
@@ -458,25 +442,25 @@ class Paiement extends CommonObject
}
}
- if (! $error) // All payments into $this->amounts were recorded without errors
+ if (!$error) // All payments into $this->amounts were recorded without errors
{
// Appel des triggers
- $result=$this->call_trigger('PAYMENT_CUSTOMER_CREATE', $user);
+ $result = $this->call_trigger('PAYMENT_CUSTOMER_CREATE', $user);
if ($result < 0) { $error++; }
// Fin appel triggers
}
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
$error++;
}
- if (! $error)
+ if (!$error)
{
- $this->amount=$total;
- $this->total=$total; // deprecated
- $this->multicurrency_amount=$mtotal;
+ $this->amount = $total;
+ $this->total = $total; // deprecated
+ $this->multicurrency_amount = $mtotal;
$this->db->commit();
return $this->id;
}
@@ -500,7 +484,7 @@ class Paiement extends CommonObject
{
global $conf, $user, $langs;
- $error=0;
+ $error = 0;
$bank_line_id = $this->bank_line;
@@ -508,12 +492,12 @@ class Paiement extends CommonObject
// Verifier si paiement porte pas sur une facture classee
// Si c'est le cas, on refuse la suppression
- $billsarray=$this->getBillsArray('fk_statut > 1');
+ $billsarray = $this->getBillsArray('fk_statut > 1');
if (is_array($billsarray))
{
if (count($billsarray))
{
- $this->error="ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
+ $this->error = "ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
$this->db->rollback();
return -1;
}
@@ -529,32 +513,32 @@ class Paiement extends CommonObject
{
$accline = new AccountLine($this->db);
- $result=$accline->fetch($bank_line_id);
- if ($result == 0) $accline->rowid=$bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url
+ $result = $accline->fetch($bank_line_id);
+ if ($result == 0) $accline->rowid = $bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url
// Delete bank account url lines linked to payment
- $result=$accline->delete_urls($user);
+ $result = $accline->delete_urls($user);
if ($result < 0)
{
- $this->error=$accline->error;
+ $this->error = $accline->error;
$this->db->rollback();
return -3;
}
// Delete bank account lines linked to payment
- $result=$accline->delete($user);
+ $result = $accline->delete($user);
if ($result < 0)
{
- $this->error=$accline->error;
+ $this->error = $accline->error;
$this->db->rollback();
return -4;
}
}
- if (! $notrigger)
+ if (!$notrigger)
{
// Call triggers
- $result=$this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user);
+ $result = $this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user);
if ($result < 0)
{
$this->db->rollback();
@@ -565,18 +549,18 @@ class Paiement extends CommonObject
// Delete payment (into paiement_facture and paiement)
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture';
- $sql.= ' WHERE fk_paiement = '.$this->id;
+ $sql .= ' WHERE fk_paiement = '.$this->id;
dol_syslog($sql);
$result = $this->db->query($sql);
if ($result)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement';
- $sql.= ' WHERE rowid = '.$this->id;
+ $sql .= ' WHERE rowid = '.$this->id;
dol_syslog($sql);
$result = $this->db->query($sql);
- if (! $result)
+ if (!$result)
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
$this->db->rollback();
return -3;
}
@@ -586,7 +570,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->error;
+ $this->error = $this->db->error;
$this->db->rollback();
return -5;
}
@@ -610,43 +594,43 @@ class Paiement extends CommonObject
{
global $conf, $langs, $user;
- $error=0;
- $bank_line_id=0;
+ $error = 0;
+ $bank_line_id = 0;
- if (! empty($conf->banque->enabled))
+ if (!empty($conf->banque->enabled))
{
if ($accountid <= 0)
{
- $this->error='Bad value for parameter accountid='.$accountid;
+ $this->error = 'Bad value for parameter accountid='.$accountid;
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR);
return -1;
}
$this->db->begin();
- $this->fk_account=$accountid;
+ $this->fk_account = $accountid;
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
dol_syslog("$user->id, $mode, $label, $this->fk_account, $emetteur_nom, $emetteur_banque");
$acc = new Account($this->db);
- $result=$acc->fetch($this->fk_account);
+ $result = $acc->fetch($this->fk_account);
- $totalamount=$this->amount;
- if (empty($totalamount)) $totalamount=$this->total; // For backward compatibility
+ $totalamount = $this->amount;
+ if (empty($totalamount)) $totalamount = $this->total; // For backward compatibility
// if dolibarr currency != bank currency then we received an amount in customer currency (currently I don't manage the case : my currency is USD, the customer currency is EUR and he paid me in GBP. Seems no sense for me)
- if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount=$this->multicurrency_amount;
+ if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount = $this->multicurrency_amount;
- if ($mode == 'payment_supplier') $totalamount=-$totalamount;
+ if ($mode == 'payment_supplier') $totalamount = -$totalamount;
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
$this->datepaye,
- $this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
+ $this->paiementid, // Payment mode id or code ("CHQ or VIR for example")
$label,
- $totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note)
+ $totalamount, // Sign must be positive when we receive money (customer payment), negative when you give money (supplier invoice or credit note)
$this->num_payment,
'',
$user,
@@ -658,7 +642,7 @@ class Paiement extends CommonObject
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0)
{
- $result=$this->update_fk_bank($bank_line_id);
+ $result = $this->update_fk_bank($bank_line_id);
if ($result <= 0)
{
$error++;
@@ -666,14 +650,14 @@ class Paiement extends CommonObject
}
// Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction
- if ( ! $error)
+ if (!$error)
{
- $url='';
- if ($mode == 'payment') $url=DOL_URL_ROOT.'/compta/paiement/card.php?id=';
- if ($mode == 'payment_supplier') $url=DOL_URL_ROOT.'/fourn/paiement/card.php?id=';
+ $url = '';
+ if ($mode == 'payment') $url = DOL_URL_ROOT.'/compta/paiement/card.php?id=';
+ if ($mode == 'payment_supplier') $url = DOL_URL_ROOT.'/fourn/paiement/card.php?id=';
if ($url)
{
- $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
+ $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0)
{
$error++;
@@ -684,9 +668,9 @@ class Paiement extends CommonObject
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
//if (! $error && $label != '(WithdrawalPayment)')
- if (! $error)
+ if (!$error)
{
- $linkaddedforthirdparty=array();
+ $linkaddedforthirdparty = array();
foreach ($this->amounts as $key => $value) // We should have invoices always for same third party but we loop in case of.
{
if ($mode == 'payment')
@@ -694,9 +678,9 @@ class Paiement extends CommonObject
$fac = new Facture($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
- if (! in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
+ if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
{
- $result=$acc->add_url_line(
+ $result = $acc->add_url_line(
$bank_line_id,
$fac->thirdparty->id,
DOL_URL_ROOT.'/comm/card.php?socid=',
@@ -704,7 +688,7 @@ class Paiement extends CommonObject
'company'
);
if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror());
- $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty
+ $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty
}
}
if ($mode == 'payment_supplier')
@@ -712,9 +696,9 @@ class Paiement extends CommonObject
$fac = new FactureFournisseur($this->db);
$fac->fetch($key);
$fac->fetch_thirdparty();
- if (! in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
+ if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
{
- $result=$acc->add_url_line(
+ $result = $acc->add_url_line(
$bank_line_id,
$fac->thirdparty->id,
DOL_URL_ROOT.'/fourn/card.php?socid=',
@@ -722,15 +706,15 @@ class Paiement extends CommonObject
'company'
);
if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror());
- $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty
+ $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty
}
}
}
}
// Add link 'WithdrawalPayment' in bank_url
- if (! $error && $label == '(WithdrawalPayment)') {
- $result=$acc->add_url_line(
+ if (!$error && $label == '(WithdrawalPayment)') {
+ $result = $acc->add_url_line(
$bank_line_id,
$this->id_prelevement,
DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
@@ -739,21 +723,21 @@ class Paiement extends CommonObject
);
}
- if (! $error && ! $notrigger)
+ if (!$error && !$notrigger)
{
// Appel des triggers
- $result=$this->call_trigger('PAYMENT_ADD_TO_BANK', $user);
+ $result = $this->call_trigger('PAYMENT_ADD_TO_BANK', $user);
if ($result < 0) { $error++; }
// Fin appel triggers
}
}
else
{
- $this->error=$acc->error;
+ $this->error = $acc->error;
$error++;
}
- if (! $error)
+ if (!$error)
{
$this->db->commit();
}
@@ -763,7 +747,7 @@ class Paiement extends CommonObject
}
}
- if (! $error)
+ if (!$error)
{
return $bank_line_id;
}
@@ -785,7 +769,7 @@ class Paiement extends CommonObject
{
// phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank;
- $sql.= ' WHERE rowid = '.$this->id;
+ $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG);
$result = $this->db->query($sql);
@@ -795,7 +779,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::update_fk_bank '.$this->error);
return -1;
}
@@ -811,7 +795,7 @@ class Paiement extends CommonObject
public function update_date($date)
{
// phpcs:enable
- $error=0;
+ $error = 0;
if (!empty($date) && $this->statut != 1)
{
@@ -820,35 +804,35 @@ class Paiement extends CommonObject
dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
- $sql.= " SET datep = '".$this->db->idate($date)."'";
- $sql.= " WHERE rowid = ".$this->id;
+ $sql .= " SET datep = '".$this->db->idate($date)."'";
+ $sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
- if (! $result)
+ if (!$result)
{
$error++;
- $this->error='Error -1 '.$this->db->error();
+ $this->error = 'Error -1 '.$this->db->error();
}
$type = $this->element;
$sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
- $sql.= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
- $sql.= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")";
- $sql.= " AND rappro = 0";
+ $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
+ $sql .= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")";
+ $sql .= " AND rappro = 0";
$result = $this->db->query($sql);
- if (! $result)
+ if (!$result)
{
$error++;
- $this->error='Error -1 '.$this->db->error();
+ $this->error = 'Error -1 '.$this->db->error();
}
- if (! $error)
+ if (!$error)
{
}
- if (! $error)
+ if (!$error)
{
$this->datepaye = $date;
$this->date = $date;
@@ -875,10 +859,10 @@ class Paiement extends CommonObject
public function update_num($num)
{
// phpcs:enable
- if(!empty($num) && $this->statut!=1) {
+ if (!empty($num) && $this->statut != 1) {
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
- $sql.= " SET num_paiement = '".$this->db->escape($num)."'";
- $sql.= " WHERE rowid = ".$this->id;
+ $sql .= " SET num_paiement = '".$this->db->escape($num)."'";
+ $sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_num", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -889,7 +873,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error='Error -1 '.$this->db->error();
+ $this->error = 'Error -1 '.$this->db->error();
return -2;
}
}
@@ -914,7 +898,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::valide '.$this->error);
return -1;
}
@@ -938,7 +922,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::reject '.$this->error);
return -1;
}
@@ -953,8 +937,8 @@ class Paiement extends CommonObject
public function info($id)
{
$sql = 'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p';
- $sql.= ' WHERE p.rowid = '.$id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p';
+ $sql .= ' WHERE p.rowid = '.$id;
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
@@ -969,7 +953,7 @@ class Paiement extends CommonObject
{
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_creat);
- $this->user_creation = $cuser;
+ $this->user_creation = $cuser;
}
if ($obj->fk_user_modif)
{
@@ -997,20 +981,20 @@ class Paiement extends CommonObject
public function getBillsArray($filter = '')
{
$sql = 'SELECT pf.fk_facture';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice
- $sql.= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
- if ($filter) $sql.= ' AND '.$filter;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice
+ $sql .= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
+ if ($filter) $sql .= ' AND '.$filter;
$resql = $this->db->query($sql);
if ($resql)
{
- $i=0;
- $num=$this->db->num_rows($resql);
- $billsarray=array();
+ $i = 0;
+ $num = $this->db->num_rows($resql);
+ $billsarray = array();
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
- $billsarray[$i]=$obj->fk_facture;
+ $billsarray[$i] = $obj->fk_facture;
$i++;
}
@@ -1018,7 +1002,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->error();
+ $this->error = $this->db->error();
dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG);
return -1;
}
@@ -1032,19 +1016,19 @@ class Paiement extends CommonObject
public function getAmountsArray()
{
$sql = 'SELECT pf.fk_facture, pf.amount';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
- $sql.= ' WHERE pf.fk_paiement = '.$this->id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
+ $sql .= ' WHERE pf.fk_paiement = '.$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
- $i=0;
- $num=$this->db->num_rows($resql);
+ $i = 0;
+ $num = $this->db->num_rows($resql);
$amounts = array();
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
- $amounts[$obj->fk_facture]=$obj->amount;
+ $amounts[$obj->fk_facture] = $obj->amount;
$i++;
}
@@ -1052,7 +1036,7 @@ class Paiement extends CommonObject
}
else
{
- $this->error=$this->db->error();
+ $this->error = $this->db->error();
dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG);
return -1;
}
@@ -1072,13 +1056,13 @@ class Paiement extends CommonObject
$langs->load("bills");
// Clean parameters (if not defined or using deprecated value)
- if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON='mod_payment_cicada';
- elseif ($conf->global->PAYMENT_ADDON=='ant') $conf->global->PAYMENT_ADDON='mod_payment_ant';
- elseif ($conf->global->PAYMENT_ADDON=='cicada') $conf->global->PAYMENT_ADDON='mod_payment_cicada';
+ if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada';
+ elseif ($conf->global->PAYMENT_ADDON == 'ant') $conf->global->PAYMENT_ADDON = 'mod_payment_ant';
+ elseif ($conf->global->PAYMENT_ADDON == 'cicada') $conf->global->PAYMENT_ADDON = 'mod_payment_cicada';
- if (! empty($conf->global->PAYMENT_ADDON))
+ if (!empty($conf->global->PAYMENT_ADDON))
{
- $mybool=false;
+ $mybool = false;
$file = $conf->global->PAYMENT_ADDON.".php";
$classname = $conf->global->PAYMENT_ADDON;
@@ -1092,12 +1076,12 @@ class Paiement extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file))
{
- $mybool |= include_once $dir . $file;
+ $mybool |= include_once $dir.$file;
}
}
// For compatibility
- if (! $mybool)
+ if (!$mybool)
{
$file = $conf->global->PAYMENT_ADDON.".php";
$classname = "mod_payment_".$conf->global->PAYMENT_ADDON;
@@ -1109,12 +1093,12 @@ class Paiement extends CommonObject
// Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) {
- $mybool |= include_once $dir . $file;
+ $mybool |= include_once $dir.$file;
}
}
}
- if (! $mybool)
+ if (!$mybool)
{
dol_print_error('', "Failed to include file ".$file);
return '';
@@ -1178,16 +1162,16 @@ class Paiement extends CommonObject
*/
public function initAsSpecimen($option = '')
{
- global $user,$langs,$conf;
+ global $user, $langs, $conf;
- $now=dol_now();
- $arraynow=dol_getdate($now);
- $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
+ $now = dol_now();
+ $arraynow = dol_getdate($now);
+ $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
// Initialize parameters
- $this->id=0;
+ $this->id = 0;
$this->ref = 'SPECIMEN';
- $this->specimen=1;
+ $this->specimen = 1;
$this->facid = 1;
$this->datepaye = $nownotime;
}
@@ -1206,49 +1190,49 @@ class Paiement extends CommonObject
{
global $conf, $langs;
- if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
- $result='';
+ $result = '';
$label = ''.$langs->trans("ShowPayment").' ';
- $label.= ''.$langs->trans("Ref").': '.$this->ref;
- if ($this->datepaye ? $this->datepaye : $this->date) $label.= ''.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
+ $label .= ''.$langs->trans("Ref").': '.$this->ref;
+ if ($this->datepaye ? $this->datepaye : $this->date) $label .= ''.$langs->trans("Date").': '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
if ($mode == 'withlistofinvoices')
{
$arraybill = $this->getBillsArray();
if (is_array($arraybill) && count($arraybill) > 0)
{
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $facturestatic=new Facture($this->db);
+ $facturestatic = new Facture($this->db);
foreach ($arraybill as $billid)
{
$facturestatic->fetch($billid);
- $label .=' '.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2, 1);
+ $label .= ' '.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2, 1);
}
}
}
- $linkclose='';
+ $linkclose = '';
if (empty($notooltip))
{
- if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
- $label=$langs->trans("ShowMyObject");
- $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ $label = $langs->trans("ShowMyObject");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
- $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
}
- else $linkclose = ($morecss?' class="'.$morecss.'"':'');
+ else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$url = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id;
$linkstart = '';
- $linkend=' ';
+ $linkstart .= $linkclose.'>';
+ $linkend = '';
$result .= $linkstart;
- if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto && $withpicto != 2) $result.= ($this->ref?$this->ref:$this->id);
+ if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ if ($withpicto && $withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id);
$result .= $linkend;
return $result;
@@ -1276,7 +1260,7 @@ class Paiement extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
- global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
+ global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
/*if ($mode == 0)
@@ -1327,7 +1311,7 @@ class Paiement extends CommonObject
public function fetch_thirdparty($force_thirdparty_id = 0)
{
// phpcs:enable
- include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (empty($force_thirdparty_id))
{
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index fdb4284e909..d998554b533 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -362,14 +362,14 @@ if ($id > 0 || $ref)
$urladd = "&id=".$id;
- print '