';
- print '| ';
- $orderstatic->id = $obj->rowid;
- $orderstatic->ref = $obj->ref;
- $orderstatic->total_ht = $obj->total_ht;
- $orderstatic->total_tva = $obj->total_tva;
- $orderstatic->total_ttc = $obj->total_ttc;
- print $orderstatic->getNomUrl(1);
- print ' | ';
+ print '';
+ $orderstatic->id = $obj->rowid;
+ $orderstatic->ref = $obj->ref;
+ $orderstatic->total_ht = $obj->total_ht;
+ $orderstatic->total_tva = $obj->total_tva;
+ $orderstatic->total_ttc = $obj->total_ttc;
+ print $orderstatic->getNomUrl(1);
+ print ' | ';
print '';
if ($obj->dc)
{
@@ -720,14 +720,14 @@ if ($object->id > 0)
$num = $db->num_rows($resql);
if ($num > 0)
{
- print '';
+ print '';
- print '';
- print '| ';
- print '';
- print ' | ';
+ print '';
+ print '| ';
+ print '';
+ print ' | ';
}
while ($i < min($num, $MAXLIST))
@@ -743,8 +743,8 @@ if ($object->id > 0)
$facturestatic->libelle = $obj->label; // deprecated
$facturestatic->label = $obj->label;
$facturestatic->total_ht = $obj->total_ht;
- $facturestatic->total_tva = $obj->total_tva;
- $facturestatic->total_ttc = $obj->total_ttc;
+ $facturestatic->total_tva = $obj->total_tva;
+ $facturestatic->total_ttc = $obj->total_ttc;
print $facturestatic->getNomUrl(1);
print $obj->ref_supplier ? ' - '.$obj->ref_supplier : '';
print ($obj->label ? ' - ' : '').dol_trunc($obj->label, 14);
@@ -780,29 +780,29 @@ if ($object->id > 0)
// modified by hook
if (empty($reshook))
{
- if ($object->status != 1)
- {
- print '';
- }
+ if ($object->status != 1)
+ {
+ print '';
+ }
if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer)
{
$langs->load("supplier_proposal");
- if ($object->status == 1) {
- print ''.$langs->trans("AddSupplierProposal").'';
- } else {
- print ''.$langs->trans("AddSupplierProposal").'';
- }
+ if ($object->status == 1) {
+ print ''.$langs->trans("AddSupplierProposal").'';
+ } else {
+ print ''.$langs->trans("AddSupplierProposal").'';
+ }
}
- if ($user->rights->fournisseur->commande->creer)
+ if ($user->rights->fournisseur->commande->creer)
{
$langs->load("orders");
- if ($object->status == 1) {
- print ''.$langs->trans("AddOrder").'';
- } else {
- print ''.$langs->trans("AddOrder").'';
- }
+ if ($object->status == 1) {
+ print ''.$langs->trans("AddOrder").'';
+ } else {
+ print ''.$langs->trans("AddOrder").'';
+ }
}
if ($user->rights->fournisseur->facture->creer)
@@ -821,23 +821,23 @@ if ($object->id > 0)
if ($user->rights->fournisseur->facture->creer)
{
$langs->load("bills");
- if ($object->status == 1) {
- print ''.$langs->trans("AddBill").'';
- } else {
- print ''.$langs->trans("AddBill").'';
- }
+ if ($object->status == 1) {
+ print ''.$langs->trans("AddBill").'';
+ } else {
+ print ''.$langs->trans("AddBill").'';
+ }
}
- // Add action
- if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1)
- {
- if ($user->rights->agenda->myactions->create)
- {
- print ''.$langs->trans("AddAction").'';
- } else {
- print ''.$langs->trans("AddAction").'';
- }
- }
+ // Add action
+ if (!empty($conf->agenda->enabled) && !empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status == 1)
+ {
+ if ($user->rights->agenda->myactions->create)
+ {
+ print ''.$langs->trans("AddAction").'';
+ } else {
+ print ''.$langs->trans("AddAction").'';
+ }
+ }
}
print '';
@@ -845,20 +845,20 @@ if ($object->id > 0)
if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD))
{
- print ' ';
- // List of contacts
- show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
+ print ' ';
+ // List of contacts
+ show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
}
if (!empty($conf->global->MAIN_REPEATTASKONEACHTAB))
{
- print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
+ print load_fiche_titre($langs->trans("ActionsOnCompany"), '', '');
- // List of todo actions
- show_actions_todo($conf, $langs, $db, $object);
+ // List of todo actions
+ show_actions_todo($conf, $langs, $db, $object);
- // List of done actions
- show_actions_done($conf, $langs, $db, $object);
+ // List of done actions
+ show_actions_done($conf, $langs, $db, $object);
}
} else {
dol_print_error($db);
diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php
index e9ba334313c..4ca073a38c7 100644
--- a/htdocs/fourn/class/fournisseur.class.php
+++ b/htdocs/fourn/class/fournisseur.class.php
@@ -100,7 +100,7 @@ class Fournisseur extends Societe
}
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load statistics indicators
*
@@ -108,7 +108,7 @@ class Fournisseur extends Societe
*/
public function load_state_board()
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $user;
$this->nb = array();
@@ -132,7 +132,7 @@ class Fournisseur extends Societe
{
$this->nb["suppliers"] = $obj->nb;
}
- $this->db->free($resql);
+ $this->db->free($resql);
return 1;
} else {
dol_print_error($this->db);
@@ -141,7 +141,7 @@ class Fournisseur extends Societe
}
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Create a supplier category
*
@@ -151,7 +151,7 @@ class Fournisseur extends Societe
*/
public function CreateCategory($user, $name)
{
- // phpcs:enable
+ // phpcs:enable
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label,visible,type)";
$sql .= " VALUES ";
$sql .= " ('".$this->db->escape($name)."',1,1)";
@@ -169,7 +169,7 @@ class Fournisseur extends Societe
}
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return the suppliers list
*
@@ -177,7 +177,7 @@ class Fournisseur extends Societe
*/
public function ListArray()
{
- // phpcs:enable
+ // phpcs:enable
global $conf;
global $user;
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 383e5ba4d07..c1ccc837232 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -388,7 +388,7 @@ class CommandeFournisseur extends CommonOrder
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
- $this->modelpdf = $obj->model_pdf; // deprecated
+ $this->modelpdf = $obj->model_pdf; // deprecated
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
@@ -2020,8 +2020,8 @@ class CommandeFournisseur extends CommonOrder
if (!$error)
{
- // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
- $this->deleteEcmFiles();
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
@@ -2210,9 +2210,9 @@ class CommandeFournisseur extends CommonOrder
// TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty).
- if (empty($error))
- {
- $this->db->begin();
+ if (empty($error))
+ {
+ $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql .= " SET fk_statut = ".$statut;
@@ -2228,10 +2228,10 @@ class CommandeFournisseur extends CommonOrder
$this->statut = $statut;
$this->actionmsg2 = $comment;
- // Call trigger
- $result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user);
- if ($result_trigger < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user);
+ if ($result_trigger < 0) $error++;
+ // End call triggers
if (empty($error))
{
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index ad7c9a1f238..c26966bc6e8 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -39,238 +39,238 @@ require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.
*/
class ProductFournisseur extends Product
{
- /**
- * @var DoliDB Database handler.
- */
- public $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- /**
- * @var string Error code (or message)
- */
- public $error = '';
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
- public $product_fourn_price_id; // id of ligne product-supplier
+ public $product_fourn_price_id; // id of ligne product-supplier
- /**
- * @var int ID
- */
- public $id;
+ /**
+ * @var int ID
+ */
+ public $id;
- /**
- * @deprecated
- * @see $ref_supplier
- */
- public $fourn_ref;
- public $delivery_time_days;
- public $ref_supplier; // ref supplier (can be set by get_buyprice)
- public $desc_supplier;
- public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
+ /**
+ * @deprecated
+ * @see $ref_supplier
+ */
+ public $fourn_ref;
+ public $delivery_time_days;
+ public $ref_supplier; // ref supplier (can be set by get_buyprice)
+ public $desc_supplier;
+ public $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice)
- public $fourn_id; //supplier id
- public $fourn_qty; // quantity for price (can be set by get_buyprice)
- public $fourn_pu; // unit price for quantity (can be set by get_buyprice)
+ public $fourn_id; //supplier id
+ public $fourn_qty; // quantity for price (can be set by get_buyprice)
+ public $fourn_pu; // unit price for quantity (can be set by get_buyprice)
- public $fourn_price; // price for quantity
- public $fourn_remise_percent; // discount for quantity (percent)
- public $fourn_remise; // discount for quantity (amount)
- public $product_fourn_id; // product-supplier id
+ public $fourn_price; // price for quantity
+ public $fourn_remise_percent; // discount for quantity (percent)
+ public $fourn_remise; // discount for quantity (amount)
+ public $product_fourn_id; // product-supplier id
- /**
- * @var int ID user_id - user who created/updated supplier price
- */
- public $user_id;
+ /**
+ * @var int ID user_id - user who created/updated supplier price
+ */
+ public $user_id;
- /**
- * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay)
- */
- public $fk_availability;
+ /**
+ * @var int ID availability delay - visible/used if option FOURN_PRODUCT_AVAILABILITY is on (duplicate information compared to delivery delay)
+ */
+ public $fk_availability;
- public $fourn_unitprice;
- public $fourn_tva_tx;
- public $fourn_tva_npr;
+ public $fourn_unitprice;
+ public $fourn_tva_tx;
+ public $fourn_tva_npr;
- /**
- * @var int ID
- */
- public $fk_supplier_price_expression;
+ /**
+ * @var int ID
+ */
+ public $fk_supplier_price_expression;
- public $supplier_reputation; // reputation of supplier
- public $reputations = array(); // list of available supplier reputations
+ public $supplier_reputation; // reputation of supplier
+ public $reputations = array(); // list of available supplier reputations
- // Multicurreny
- public $fourn_multicurrency_id;
- public $fourn_multicurrency_code;
- public $fourn_multicurrency_tx;
- public $fourn_multicurrency_price;
- public $fourn_multicurrency_unitprice;
+ // Multicurreny
+ public $fourn_multicurrency_id;
+ public $fourn_multicurrency_code;
+ public $fourn_multicurrency_tx;
+ public $fourn_multicurrency_price;
+ public $fourn_multicurrency_unitprice;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- global $langs;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs;
- $this->db = $db;
- $langs->load("suppliers");
- $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
- }
+ $this->db = $db;
+ $langs->load("suppliers");
+ $this->reputations = array('-1'=>'', 'FAVORITE'=>$langs->trans('Favorite'), 'NOTTHGOOD'=>$langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER'=>$langs->trans('DoNotOrderThisProductToThisSupplier'));
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Remove all prices for this couple supplier-product
- *
- * @param int $id_fourn Supplier Id
- * @return int < 0 if error, > 0 if ok
- */
- public function remove_fournisseur($id_fourn)
- {
- // phpcs:enable
- $ok = 1;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Remove all prices for this couple supplier-product
+ *
+ * @param int $id_fourn Supplier Id
+ * @return int < 0 if error, > 0 if ok
+ */
+ public function remove_fournisseur($id_fourn)
+ {
+ // phpcs:enable
+ $ok = 1;
- $this->db->begin();
+ $this->db->begin();
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
- $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql .= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn;
- dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG);
- $resql2 = $this->db->query($sql);
- if (!$resql2)
- {
- $this->error = $this->db->lasterror();
- $ok = 0;
- }
+ dol_syslog(get_class($this)."::remove_fournisseur", LOG_DEBUG);
+ $resql2 = $this->db->query($sql);
+ if (!$resql2)
+ {
+ $this->error = $this->db->lasterror();
+ $ok = 0;
+ }
- if ($ok)
- {
- $this->db->commit();
- return 1;
- } else {
- $this->db->rollback();
- return -1;
- }
- }
+ if ($ok)
+ {
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Remove a price for a couple supplier-product
- *
- * @param int $rowid Line id of price
- * @return int <0 if KO, >0 if OK
- */
- public function remove_product_fournisseur_price($rowid)
- {
- // phpcs:enable
- global $conf, $user;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Remove a price for a couple supplier-product
+ *
+ * @param int $rowid Line id of price
+ * @return int <0 if KO, >0 if OK
+ */
+ public function remove_product_fournisseur_price($rowid)
+ {
+ // phpcs:enable
+ global $conf, $user;
- $error = 0;
+ $error = 0;
- $this->db->begin();
+ $this->db->begin();
- // Call trigger
- $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_DELETE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
- if (empty($error))
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
- $sql .= " WHERE rowid = ".$rowid;
+ if (empty($error))
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql .= " WHERE rowid = ".$rowid;
- dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->error = $this->db->lasterror();
- $error++;
- }
- }
+ dol_syslog(get_class($this)."::remove_product_fournisseur_price", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql)
+ {
+ $this->error = $this->db->lasterror();
+ $error++;
+ }
+ }
- if (empty($error)) {
- $this->db->commit();
- return 1;
- } else {
- $this->db->rollback();
- return -1;
- }
- }
+ if (empty($error)) {
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Modify the purchase price for a supplier
- *
- * @param float $qty Min quantity for which price is valid
- * @param float $buyprice Purchase price for the quantity min
- * @param User $user Object user user made changes
- * @param string $price_base_type HT or TTC
- * @param Societe $fourn Supplier
- * @param int $availability Product availability
- * @param string $ref_fourn Supplier ref
- * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string)
- * @param string $charges costs affering to product
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Modify the purchase price for a supplier
+ *
+ * @param float $qty Min quantity for which price is valid
+ * @param float $buyprice Purchase price for the quantity min
+ * @param User $user Object user user made changes
+ * @param string $price_base_type HT or TTC
+ * @param Societe $fourn Supplier
+ * @param int $availability Product availability
+ * @param string $ref_fourn Supplier ref
+ * @param float $tva_tx New VAT Rate (For example 8.5. Should not be a string)
+ * @param string $charges costs affering to product
* @param float $remise_percent Discount regarding qty (percent)
* @param float $remise Discount regarding qty (amount)
* @param int $newnpr Set NPR or not
* @param int $delivery_time_days Delay in days for delivery (max). May be '' if not defined.
* @param string $supplier_reputation Reputation with this product to the defined supplier (empty, FAVORITE, DONOTORDER)
- * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
- * @param string $newdefaultvatcode Default vat code
- * @param float $multicurrency_buyprice Purchase price for the quantity min in currency
- * @param string $multicurrency_price_base_type HT or TTC in currency
- * @param float $multicurrency_tx Rate currency
- * @param string $multicurrency_code Currency code
- * @param string $desc_fourn Custom description for product_fourn_price
- * @param string $barcode Barcode
- * @param int $fk_barcode_type Barcode type
- * @return int <0 if KO, >=0 if OK
- */
- public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '')
- {
- // phpcs:enable
- global $conf, $langs;
- //global $mysoc;
+ * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function).
+ * @param string $newdefaultvatcode Default vat code
+ * @param float $multicurrency_buyprice Purchase price for the quantity min in currency
+ * @param string $multicurrency_price_base_type HT or TTC in currency
+ * @param float $multicurrency_tx Rate currency
+ * @param string $multicurrency_code Currency code
+ * @param string $desc_fourn Custom description for product_fourn_price
+ * @param string $barcode Barcode
+ * @param int $fk_barcode_type Barcode type
+ * @return int <0 if KO, >=0 if OK
+ */
+ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '')
+ {
+ // phpcs:enable
+ global $conf, $langs;
+ //global $mysoc;
- // Clean parameter
- if (empty($qty)) $qty = 0;
- if (empty($buyprice)) $buyprice = 0;
- if (empty($charges)) $charges = 0;
- if (empty($availability)) $availability = 0;
- if (empty($remise_percent)) $remise_percent = 0;
- if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = '';
- if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = '';
- if ($price_base_type == 'TTC')
- {
- $ttx = $tva_tx;
- $buyprice = $buyprice / (1 + ($ttx / 100));
- }
+ // Clean parameter
+ if (empty($qty)) $qty = 0;
+ if (empty($buyprice)) $buyprice = 0;
+ if (empty($charges)) $charges = 0;
+ if (empty($availability)) $availability = 0;
+ if (empty($remise_percent)) $remise_percent = 0;
+ if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation = '';
+ if ($delivery_time_days != '' && !is_numeric($delivery_time_days)) $delivery_time_days = '';
+ if ($price_base_type == 'TTC')
+ {
+ $ttx = $tva_tx;
+ $buyprice = $buyprice / (1 + ($ttx / 100));
+ }
// Multicurrency
- if ($conf->multicurrency->enabled) {
- if (empty($multicurrency_tx)) $multicurrency_tx = 1;
- if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
+ if ($conf->multicurrency->enabled) {
+ if (empty($multicurrency_tx)) $multicurrency_tx = 1;
+ if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
- if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
- if ($multicurrency_price_base_type == 'TTC')
- {
- $ttx = $tva_tx;
- $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100));
- }
- $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU');
- $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU');
+ if (empty($multicurrency_buyprice)) $multicurrency_buyprice = 0;
+ if ($multicurrency_price_base_type == 'TTC')
+ {
+ $ttx = $tva_tx;
+ $multicurrency_buyprice = $multicurrency_buyprice / (1 + ($ttx / 100));
+ }
+ $multicurrency_buyprice = price2num($multicurrency_buyprice, 'MU');
+ $multicurrency_unitBuyPrice = price2num($multicurrency_buyprice / $qty, 'MU');
- $buyprice = $multicurrency_buyprice / $multicurrency_tx;
- $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code);
- }
+ $buyprice = $multicurrency_buyprice / $multicurrency_tx;
+ $fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $multicurrency_code);
+ }
- $buyprice = price2num($buyprice, 'MU');
+ $buyprice = price2num($buyprice, 'MU');
$charges = price2num($charges, 'MU');
- $qty = price2num($qty, 'MS');
+ $qty = price2num($qty, 'MS');
$unitBuyPrice = price2num($buyprice / $qty, 'MU');
$packaging = price2num((($this->packaging < $qty) ? $qty : $this->packaging), 'MS');
@@ -300,50 +300,50 @@ class ProductFournisseur extends Product
{
}
- $this->db->begin();
+ $this->db->begin();
- if ($this->product_fourn_price_id > 0)
- {
- // check if price already logged, if not first log current price
- $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id);
- if (is_array($logPrices) && count($logPrices) == 0)
- {
- $currentPfp = new self($this->db);
- $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
- if ($result > 0 && $currentPfp->fourn_price != 0)
- {
- $currentPfpUser = new User($this->db);
- $result = $currentPfpUser->fetch($currentPfp->user_id);
- if ($result > 0) {
- $currentPfp->logPrice(
- $currentPfpUser,
- $currentPfp->date_creation,
- $currentPfp->fourn_price,
- $currentPfp->fourn_qty,
- $currentPfp->fourn_multicurrency_price,
- $currentPfp->fourn_multicurrency_unitprice,
- $currentPfp->fourn_multicurrency_tx,
- $currentPfp->fourn_multicurrency_id,
- $currentPfp->fourn_multicurrency_code
- );
- }
- }
- }
- $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
+ if ($this->product_fourn_price_id > 0)
+ {
+ // check if price already logged, if not first log current price
+ $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id);
+ if (is_array($logPrices) && count($logPrices) == 0)
+ {
+ $currentPfp = new self($this->db);
+ $result = $currentPfp->fetch_product_fournisseur_price($this->product_fourn_price_id);
+ if ($result > 0 && $currentPfp->fourn_price != 0)
+ {
+ $currentPfpUser = new User($this->db);
+ $result = $currentPfpUser->fetch($currentPfp->user_id);
+ if ($result > 0) {
+ $currentPfp->logPrice(
+ $currentPfpUser,
+ $currentPfp->date_creation,
+ $currentPfp->fourn_price,
+ $currentPfp->fourn_qty,
+ $currentPfp->fourn_multicurrency_price,
+ $currentPfp->fourn_multicurrency_unitprice,
+ $currentPfp->fourn_multicurrency_tx,
+ $currentPfp->fourn_multicurrency_id,
+ $currentPfp->fourn_multicurrency_code
+ );
+ }
+ }
+ }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET fk_user = ".$user->id." ,";
- $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',";
- $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',";
+ $sql .= " ref_fourn = '".$this->db->escape($ref_fourn)."',";
+ $sql .= " desc_fourn = '".$this->db->escape($desc_fourn)."',";
$sql .= " price = ".$buyprice.",";
$sql .= " quantity = ".$qty.",";
$sql .= " remise_percent = ".$remise_percent.",";
$sql .= " remise = ".$remise.",";
$sql .= " unitprice = ".$unitBuyPrice.",";
$sql .= " fk_availability = ".$availability.",";
- $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
- $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
- $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
- $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
- $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
+ $sql .= " multicurrency_price = ".(isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
+ $sql .= " multicurrency_unitprice = ".(isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
+ $sql .= " multicurrency_tx = ".(isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
+ $sql .= " fk_multicurrency = ".(isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
+ $sql .= " multicurrency_code = ".(isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
$sql .= " entity = ".$conf->entity.",";
$sql .= " tva_tx = ".price2num($tva_tx).",";
// TODO Add localtax1 and localtax2
@@ -356,8 +356,8 @@ class ProductFournisseur extends Product
$sql .= " charges = ".$charges.","; // deprecated
$sql .= " delivery_time_days = ".($delivery_time_days != '' ? $delivery_time_days : 'null').",";
$sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
- $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
- $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ $sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
+ $sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging);
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
// TODO Add price_base_type and price_ttc
@@ -366,17 +366,17 @@ class ProductFournisseur extends Product
$resql = $this->db->query($sql);
if ($resql)
{
- // Call trigger
- $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user);
- if ($result < 0) $error++;
- // End call triggers
- if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG))
- {
- $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
- if ($result < 0) {
- $error++;
- }
- }
+ // Call trigger
+ $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG))
+ {
+ $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
+ if ($result < 0) {
+ $error++;
+ }
+ }
if (empty($error))
{
$this->db->commit();
@@ -390,727 +390,727 @@ class ProductFournisseur extends Product
$this->db->rollback();
return -2;
}
- } else {
- dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG);
+ } else {
+ dol_syslog(get_class($this).'::update_buyprice without knowing id of line, so we delete from company, quantity and supplier_ref and insert again', LOG_DEBUG);
- // Delete price for this quantity
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
- $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity;
- $resql = $this->db->query($sql);
- if ($resql) {
- // Add price for this quantity to supplier
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
- $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
- $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
+ // Delete price for this quantity
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql .= " WHERE fk_soc = ".$fourn->id." AND ref_fourn = '".$this->db->escape($ref_fourn)."' AND quantity = ".$qty." AND entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ // Add price for this quantity to supplier
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
+ $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
+ $sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging";
- $sql .= " values(";
- $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
- $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
- $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
- $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
- $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
- $sql .= " '".$this->db->idate($now)."',";
- $sql .= " ".$this->id.",";
- $sql .= " ".$fourn->id.",";
- $sql .= " '".$this->db->escape($ref_fourn)."',";
- $sql .= " '".$this->db->escape($desc_fourn)."',";
- $sql .= " ".$user->id.",";
- $sql .= " ".$buyprice.",";
- $sql .= " ".$qty.",";
- $sql .= " ".$remise_percent.",";
- $sql .= " ".$remise.",";
- $sql .= " ".$unitBuyPrice.",";
- $sql .= " ".$tva_tx.",";
- $sql .= " ".$charges.",";
- $sql .= " ".$availability.",";
- $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
- $sql .= " ".$newnpr.",";
- $sql .= $conf->entity.",";
- $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').",";
- $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
- $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
- $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ $sql .= " values(";
+ $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
+ $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
+ $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
+ $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
+ $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
+ $sql .= " '".$this->db->idate($now)."',";
+ $sql .= " ".$this->id.",";
+ $sql .= " ".$fourn->id.",";
+ $sql .= " '".$this->db->escape($ref_fourn)."',";
+ $sql .= " '".$this->db->escape($desc_fourn)."',";
+ $sql .= " ".$user->id.",";
+ $sql .= " ".$buyprice.",";
+ $sql .= " ".$qty.",";
+ $sql .= " ".$remise_percent.",";
+ $sql .= " ".$remise.",";
+ $sql .= " ".$unitBuyPrice.",";
+ $sql .= " ".$tva_tx.",";
+ $sql .= " ".$charges.",";
+ $sql .= " ".$availability.",";
+ $sql .= " ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
+ $sql .= " ".$newnpr.",";
+ $sql .= $conf->entity.",";
+ $sql .= ($delivery_time_days != '' ? $delivery_time_days : 'null').",";
+ $sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
+ $sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
+ $sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging));
- $sql .= ")";
+ $sql .= ")";
$this->product_fourn_price_id = 0;
- $resql = $this->db->query($sql);
- if ($resql) {
- $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
- } else {
- $error++;
- }
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
+ } else {
+ $error++;
+ }
- if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
- // Add record into log table
+ if (!$error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) {
+ // Add record into log table
// $this->product_fourn_price_id must be set
- $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
- if ($result < 0) {
- $error++;
- }
- }
+ $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
+ if ($result < 0) {
+ $error++;
+ }
+ }
- if (!$error) {
- // Call trigger
- $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user);
- if ($result < 0)
- $error++;
- // End call triggers
+ if (!$error) {
+ // Call trigger
+ $result = $this->call_trigger('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $user);
+ if ($result < 0)
+ $error++;
+ // End call triggers
- if (empty($error)) {
- $this->db->commit();
- return $this->product_fourn_price_id;
- } else {
- $this->db->rollback();
- return -1;
- }
- } else {
- $this->error = $this->db->lasterror()." sql=".$sql;
- $this->db->rollback();
- return -2;
- }
- } else {
- $this->error = $this->db->lasterror()." sql=".$sql;
- $this->db->rollback();
- return -1;
- }
- }
- }
+ if (empty($error)) {
+ $this->db->commit();
+ return $this->product_fourn_price_id;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ } else {
+ $this->error = $this->db->lasterror()." sql=".$sql;
+ $this->db->rollback();
+ return -2;
+ }
+ } else {
+ $this->error = $this->db->lasterror()." sql=".$sql;
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Loads the price information of a provider
- *
- * @param int $rowid Line id
- * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead
- * @return int < 0 if KO, 0 if OK but not found, > 0 if OK
- */
- public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
- {
- // phpcs:enable
- global $conf;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Loads the price information of a provider
+ *
+ * @param int $rowid Line id
+ * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead
+ * @return int < 0 if KO, 0 if OK but not found, > 0 if OK
+ */
+ public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0)
+ {
+ // phpcs:enable
+ global $conf;
- $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
- $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
- $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
- $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
- $sql .= " pfp.barcode, pfp.fk_barcode_type";
+ $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.info_bits as fourn_tva_npr, pfp.fk_availability,";
+ $sql .= " pfp.fk_soc, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,";
+ $sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
+ $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
+ $sql .= " pfp.barcode, pfp.fk_barcode_type";
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
- $sql .= " WHERE pfp.rowid = ".(int) $rowid;
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql .= " WHERE pfp.rowid = ".(int) $rowid;
- dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $obj = $this->db->fetch_object($resql);
- if ($obj)
- {
- $this->product_fourn_price_id = $rowid;
- $this->id = $obj->fk_product;
- $this->fk_product = $obj->fk_product;
- $this->product_id = $obj->fk_product; // deprecated
- $this->fourn_id = $obj->fk_soc;
- $this->fourn_ref = $obj->ref_fourn; // deprecated
- $this->ref_supplier = $obj->ref_fourn;
- $this->desc_supplier = $obj->desc_fourn;
- $this->fourn_price = $obj->price;
- $this->fourn_charges = $obj->charges; // deprecated
- $this->fourn_qty = $obj->quantity;
- $this->fourn_remise_percent = $obj->remise_percent;
- $this->fourn_remise = $obj->remise;
- $this->fourn_unitprice = $obj->unitprice;
- $this->fourn_tva_tx = $obj->tva_tx;
- $this->fourn_tva_npr = $obj->fourn_tva_npr;
- // Add also localtaxes
- $this->fk_availability = $obj->fk_availability;
+ dol_syslog(get_class($this)."::fetch_product_fournisseur_price", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj)
+ {
+ $this->product_fourn_price_id = $rowid;
+ $this->id = $obj->fk_product;
+ $this->fk_product = $obj->fk_product;
+ $this->product_id = $obj->fk_product; // deprecated
+ $this->fourn_id = $obj->fk_soc;
+ $this->fourn_ref = $obj->ref_fourn; // deprecated
+ $this->ref_supplier = $obj->ref_fourn;
+ $this->desc_supplier = $obj->desc_fourn;
+ $this->fourn_price = $obj->price;
+ $this->fourn_charges = $obj->charges; // deprecated
+ $this->fourn_qty = $obj->quantity;
+ $this->fourn_remise_percent = $obj->remise_percent;
+ $this->fourn_remise = $obj->remise;
+ $this->fourn_unitprice = $obj->unitprice;
+ $this->fourn_tva_tx = $obj->tva_tx;
+ $this->fourn_tva_npr = $obj->fourn_tva_npr;
+ // Add also localtaxes
+ $this->fk_availability = $obj->fk_availability;
$this->delivery_time_days = $obj->delivery_time_days;
- $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
- $this->supplier_reputation = $obj->supplier_reputation;
- $this->default_vat_code = $obj->default_vat_code;
- $this->user_id = $obj->fk_user;
- $this->date_creation = $this->db->jdate($obj->datec);
- $this->fourn_multicurrency_price = $obj->multicurrency_price;
- $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice;
- $this->fourn_multicurrency_tx = $obj->multicurrency_tx;
- $this->fourn_multicurrency_id = $obj->fk_multicurrency;
- $this->fourn_multicurrency_code = $obj->multicurrency_code;
- if ($conf->barcode->enabled) {
- $this->fourn_barcode = $obj->barcode;
- $this->fourn_fk_barcode_type = $obj->fk_barcode_type;
- }
+ $this->fk_supplier_price_expression = $obj->fk_supplier_price_expression;
+ $this->supplier_reputation = $obj->supplier_reputation;
+ $this->default_vat_code = $obj->default_vat_code;
+ $this->user_id = $obj->fk_user;
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->fourn_multicurrency_price = $obj->multicurrency_price;
+ $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice;
+ $this->fourn_multicurrency_tx = $obj->multicurrency_tx;
+ $this->fourn_multicurrency_id = $obj->fk_multicurrency;
+ $this->fourn_multicurrency_code = $obj->multicurrency_code;
+ if ($conf->barcode->enabled) {
+ $this->fourn_barcode = $obj->barcode;
+ $this->fourn_fk_barcode_type = $obj->fk_barcode_type;
+ }
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
$this->packaging = $obj->packaging;
if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty;
}
- if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
- {
- $priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parseProductSupplier($this);
- if ($price_result >= 0) {
- $this->fourn_price = $price_result;
- //recalculation of unitprice, as probably the price changed...
- if ($this->fourn_qty != 0)
- {
- $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU');
- } else {
- $this->fourn_unitprice = "";
- }
- }
- }
+ if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
+ {
+ $priceparser = new PriceParser($this->db);
+ $price_result = $priceparser->parseProductSupplier($this);
+ if ($price_result >= 0) {
+ $this->fourn_price = $price_result;
+ //recalculation of unitprice, as probably the price changed...
+ if ($this->fourn_qty != 0)
+ {
+ $this->fourn_unitprice = price2num($this->fourn_price / $this->fourn_qty, 'MU');
+ } else {
+ $this->fourn_unitprice = "";
+ }
+ }
+ }
- return 1;
- } else {
- return 0;
- }
- } else {
- $this->error = $this->db->error();
- return -1;
- }
- }
+ return 1;
+ } else {
+ return 0;
+ }
+ } else {
+ $this->error = $this->db->error();
+ return -1;
+ }
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * List all supplier prices of a product
- *
- * @param int $prodid Id of product
- * @param string $sortfield Sort field
- * @param string $sortorder Sort order
- * @param int $limit Limit
- * @param int $offset Offset
- * @return array Array of Products with new properties to define supplier price
- */
- public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)
- {
- // phpcs:enable
- global $conf;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * List all supplier prices of a product
+ *
+ * @param int $prodid Id of product
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @return array Array of Products with new properties to define supplier price
+ */
+ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)
+ {
+ // phpcs:enable
+ global $conf;
- $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
- $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
- $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
- $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
- $sql .= " pfp.barcode, pfp.fk_barcode_type";
+ $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
+ $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,";
+ $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
+ $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
+ $sql .= " pfp.barcode, pfp.fk_barcode_type";
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
- $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
- $sql .= " AND pfp.fk_soc = s.rowid";
- $sql .= " AND s.status=1"; // only enabled company selected
- $sql .= " AND pfp.fk_product = ".$prodid;
- if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price";
- else $sql .= $this->db->order($sortfield, $sortorder);
- $sql .= $this->db->plimit($limit, $offset);
- dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG);
+ $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
+ $sql .= " AND pfp.fk_soc = s.rowid";
+ $sql .= " AND s.status=1"; // only enabled company selected
+ $sql .= " AND pfp.fk_product = ".$prodid;
+ if (empty($sortfield)) $sql .= " ORDER BY s.nom, pfp.quantity, pfp.price";
+ else $sql .= $this->db->order($sortfield, $sortorder);
+ $sql .= $this->db->plimit($limit, $offset);
+ dol_syslog(get_class($this)."::list_product_fournisseur_price", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $retarray = array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $retarray = array();
- while ($record = $this->db->fetch_array($resql))
- {
- //define base attribute
- $prodfourn = new ProductFournisseur($this->db);
+ while ($record = $this->db->fetch_array($resql))
+ {
+ //define base attribute
+ $prodfourn = new ProductFournisseur($this->db);
- $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"];
- $prodfourn->product_fourn_id = $record["product_fourn_id"];
- $prodfourn->product_fourn_entity = $record["entity"];
- $prodfourn->fourn_ref = $record["ref_fourn"];
- $prodfourn->ref_supplier = $record["ref_fourn"];
- $prodfourn->desc_supplier = $record["desc_fourn"];
- $prodfourn->fourn_price = $record["price"];
- $prodfourn->fourn_qty = $record["quantity"];
+ $prodfourn->product_fourn_price_id = $record["product_fourn_pri_id"];
+ $prodfourn->product_fourn_id = $record["product_fourn_id"];
+ $prodfourn->product_fourn_entity = $record["entity"];
+ $prodfourn->fourn_ref = $record["ref_fourn"];
+ $prodfourn->ref_supplier = $record["ref_fourn"];
+ $prodfourn->desc_supplier = $record["desc_fourn"];
+ $prodfourn->fourn_price = $record["price"];
+ $prodfourn->fourn_qty = $record["quantity"];
$prodfourn->fourn_remise_percent = $record["remise_percent"];
$prodfourn->fourn_remise = $record["remise"];
$prodfourn->fourn_unitprice = $record["unitprice"];
$prodfourn->fourn_charges = $record["charges"]; // deprecated
- $prodfourn->fourn_tva_tx = $record["tva_tx"];
- $prodfourn->fourn_id = $record["fourn_id"];
- $prodfourn->fourn_name = $record["supplier_name"];
- $prodfourn->fk_availability = $record["fk_availability"];
+ $prodfourn->fourn_tva_tx = $record["tva_tx"];
+ $prodfourn->fourn_id = $record["fourn_id"];
+ $prodfourn->fourn_name = $record["supplier_name"];
+ $prodfourn->fk_availability = $record["fk_availability"];
$prodfourn->delivery_time_days = $record["delivery_time_days"];
- $prodfourn->id = $prodid;
- $prodfourn->fourn_tva_npr = $record["info_bits"];
- $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
+ $prodfourn->id = $prodid;
+ $prodfourn->fourn_tva_npr = $record["info_bits"];
+ $prodfourn->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
$prodfourn->supplier_reputation = $record["supplier_reputation"];
$prodfourn->fourn_date_creation = $this->db->jdate($record['datec']);
$prodfourn->fourn_date_modification = $this->db->jdate($record['tms']);
- $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"];
- $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
- $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"];
- $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
- $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
+ $prodfourn->fourn_multicurrency_price = $record["multicurrency_price"];
+ $prodfourn->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
+ $prodfourn->fourn_multicurrency_tx = $record["multicurrency_tx"];
+ $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
+ $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
$prodfourn->packaging = $record["packaging"];
if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty;
}
- if ($conf->barcode->enabled) {
- $prodfourn->barcode = $record["barcode"];
- $prodfourn->fk_barcode_type = $record["fk_barcode_type"];
- }
+ if ($conf->barcode->enabled) {
+ $prodfourn->barcode = $record["barcode"];
+ $prodfourn->fk_barcode_type = $record["fk_barcode_type"];
+ }
- if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
- $priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parseProductSupplier($prodfourn);
- if ($price_result >= 0) {
- $prodfourn->fourn_price = $price_result;
- $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed...
- }
- }
+ if (!empty($conf->dynamicprices->enabled) && !empty($prodfourn->fk_supplier_price_expression)) {
+ $priceparser = new PriceParser($this->db);
+ $price_result = $priceparser->parseProductSupplier($prodfourn);
+ if ($price_result >= 0) {
+ $prodfourn->fourn_price = $price_result;
+ $prodfourn->fourn_unitprice = null; //force recalculation of unitprice, as probably the price changed...
+ }
+ }
- if (!isset($prodfourn->fourn_unitprice))
- {
- if ($prodfourn->fourn_qty != 0)
- {
- $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU');
- } else {
- $prodfourn->fourn_unitprice = "";
- }
- }
+ if (!isset($prodfourn->fourn_unitprice))
+ {
+ if ($prodfourn->fourn_qty != 0)
+ {
+ $prodfourn->fourn_unitprice = price2num($prodfourn->fourn_price / $prodfourn->fourn_qty, 'MU');
+ } else {
+ $prodfourn->fourn_unitprice = "";
+ }
+ }
- $retarray[] = $prodfourn;
- }
+ $retarray[] = $prodfourn;
+ }
- $this->db->free($resql);
- return $retarray;
- } else {
- $this->error = $this->db->error();
- return -1;
- }
- }
+ $this->db->free($resql);
+ return $retarray;
+ } else {
+ $this->error = $this->db->error();
+ return -1;
+ }
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Load properties for minimum price
- *
- * @param int $prodid Product id
- * @param int $qty Minimum quantity
- * @param int $socid get min price for specific supplier
- * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
- */
- public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0)
- {
- // phpcs:enable
- global $conf;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Load properties for minimum price
+ *
+ * @param int $prodid Product id
+ * @param int $qty Minimum quantity
+ * @param int $socid get min price for specific supplier
+ * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
+ */
+ public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0)
+ {
+ // phpcs:enable
+ global $conf;
- if (empty($prodid))
- {
- dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
- return 0;
- }
+ if (empty($prodid))
+ {
+ dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
+ return 0;
+ }
- $this->product_fourn_price_id = '';
- $this->product_fourn_id = '';
- $this->fourn_ref = '';
- $this->fourn_price = '';
- $this->fourn_qty = '';
- $this->fourn_remise_percent = '';
- $this->fourn_remise = '';
- $this->fourn_unitprice = '';
- $this->fourn_id = '';
- $this->fourn_name = '';
+ $this->product_fourn_price_id = '';
+ $this->product_fourn_id = '';
+ $this->fourn_ref = '';
+ $this->fourn_price = '';
+ $this->fourn_qty = '';
+ $this->fourn_remise_percent = '';
+ $this->fourn_remise = '';
+ $this->fourn_unitprice = '';
+ $this->fourn_id = '';
+ $this->fourn_name = '';
$this->delivery_time_days = '';
- $this->id = '';
+ $this->id = '';
- $this->fourn_multicurrency_price = '';
- $this->fourn_multicurrency_unitprice = '';
- $this->fourn_multicurrency_tx = '';
- $this->fourn_multicurrency_id = '';
- $this->fourn_multicurrency_code = '';
+ $this->fourn_multicurrency_price = '';
+ $this->fourn_multicurrency_unitprice = '';
+ $this->fourn_multicurrency_tx = '';
+ $this->fourn_multicurrency_id = '';
+ $this->fourn_multicurrency_code = '';
- $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
- $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
- $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
- $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
- $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
- $sql .= " WHERE s.entity IN (".getEntity('societe').")";
- $sql .= " AND pfp.entity = ".$conf->entity; // only current entity
- $sql .= " AND pfp.fk_product = ".$prodid;
- $sql .= " AND pfp.fk_soc = s.rowid";
- $sql .= " AND s.status = 1"; // only enabled society
- if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty;
+ $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,";
+ $sql .= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,";
+ $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,";
+ $sql .= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days";
+ $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
+ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql .= " WHERE s.entity IN (".getEntity('societe').")";
+ $sql .= " AND pfp.entity = ".$conf->entity; // only current entity
+ $sql .= " AND pfp.fk_product = ".$prodid;
+ $sql .= " AND pfp.fk_soc = s.rowid";
+ $sql .= " AND s.status = 1"; // only enabled society
+ if ($qty > 0) $sql .= " AND pfp.quantity <= ".$qty;
if ($socid > 0) $sql .= ' AND pfp.fk_soc = '.$socid;
- dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG);
+ dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $record_array = array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $record_array = array();
- //Store each record to array for later search of min
- while ($record = $this->db->fetch_array($resql))
- {
- $record_array[] = $record;
- }
+ //Store each record to array for later search of min
+ while ($record = $this->db->fetch_array($resql))
+ {
+ $record_array[] = $record;
+ }
- if (count($record_array) == 0)
- {
- $this->db->free($resql);
- return 0;
- } else {
- $min = -1;
- foreach ($record_array as $record)
- {
- $fourn_price = $record["price"];
- // discount calculated buy price
- $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"];
- if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) {
- $prod_supplier = new ProductFournisseur($this->db);
- $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"];
- $prod_supplier->id = $prodid;
- $prod_supplier->fourn_qty = $record["quantity"];
- $prod_supplier->fourn_tva_tx = $record["tva_tx"];
- $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
- $priceparser = new PriceParser($this->db);
- $price_result = $priceparser->parseProductSupplier($prod_supplier);
- if ($price_result >= 0) {
- $fourn_price = price2num($price_result, 'MU');
- if ($record["quantity"] != 0)
- {
- $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU');
- } else {
- $fourn_unitprice = $fourn_price;
- }
- }
- }
- if ($fourn_unitprice < $min || $min == -1)
- {
- $this->product_fourn_price_id = $record["product_fourn_price_id"];
- $this->ref_supplier = $record["ref_fourn"];
- $this->ref_fourn = $record["ref_fourn"]; // deprecated
- $this->fourn_ref = $record["ref_fourn"]; // deprecated
- $this->fourn_price = $fourn_price;
- $this->fourn_qty = $record["quantity"];
- $this->fourn_remise_percent = $record["remise_percent"];
- $this->fourn_remise = $record["remise"];
- $this->fourn_unitprice = $record["unitprice"];
- $this->fourn_charges = $record["charges"]; // deprecated
- $this->fourn_tva_tx = $record["tva_tx"];
- $this->fourn_id = $record["fourn_id"];
- $this->fourn_name = $record["supplier_name"];
+ if (count($record_array) == 0)
+ {
+ $this->db->free($resql);
+ return 0;
+ } else {
+ $min = -1;
+ foreach ($record_array as $record)
+ {
+ $fourn_price = $record["price"];
+ // discount calculated buy price
+ $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"];
+ if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) {
+ $prod_supplier = new ProductFournisseur($this->db);
+ $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"];
+ $prod_supplier->id = $prodid;
+ $prod_supplier->fourn_qty = $record["quantity"];
+ $prod_supplier->fourn_tva_tx = $record["tva_tx"];
+ $prod_supplier->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
+ $priceparser = new PriceParser($this->db);
+ $price_result = $priceparser->parseProductSupplier($prod_supplier);
+ if ($price_result >= 0) {
+ $fourn_price = price2num($price_result, 'MU');
+ if ($record["quantity"] != 0)
+ {
+ $fourn_unitprice = price2num($fourn_price / $record["quantity"], 'MU');
+ } else {
+ $fourn_unitprice = $fourn_price;
+ }
+ }
+ }
+ if ($fourn_unitprice < $min || $min == -1)
+ {
+ $this->product_fourn_price_id = $record["product_fourn_price_id"];
+ $this->ref_supplier = $record["ref_fourn"];
+ $this->ref_fourn = $record["ref_fourn"]; // deprecated
+ $this->fourn_ref = $record["ref_fourn"]; // deprecated
+ $this->fourn_price = $fourn_price;
+ $this->fourn_qty = $record["quantity"];
+ $this->fourn_remise_percent = $record["remise_percent"];
+ $this->fourn_remise = $record["remise"];
+ $this->fourn_unitprice = $record["unitprice"];
+ $this->fourn_charges = $record["charges"]; // deprecated
+ $this->fourn_tva_tx = $record["tva_tx"];
+ $this->fourn_id = $record["fourn_id"];
+ $this->fourn_name = $record["supplier_name"];
$this->delivery_time_days = $record["delivery_time_days"];
- $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
- $this->id = $prodid;
- $this->fourn_multicurrency_price = $record["multicurrency_price"];
- $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
- $this->fourn_multicurrency_tx = $record["multicurrency_tx"];
- $this->fourn_multicurrency_id = $record["fk_multicurrency"];
- $this->fourn_multicurrency_code = $record["multicurrency_code"];
- $min = $fourn_unitprice;
- }
- }
- }
+ $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"];
+ $this->id = $prodid;
+ $this->fourn_multicurrency_price = $record["multicurrency_price"];
+ $this->fourn_multicurrency_unitprice = $record["multicurrency_unitprice"];
+ $this->fourn_multicurrency_tx = $record["multicurrency_tx"];
+ $this->fourn_multicurrency_id = $record["fk_multicurrency"];
+ $this->fourn_multicurrency_code = $record["multicurrency_code"];
+ $min = $fourn_unitprice;
+ }
+ }
+ }
- $this->db->free($resql);
- return 1;
- } else {
- $this->error = $this->db->error();
- return -1;
- }
- }
+ $this->db->free($resql);
+ return 1;
+ } else {
+ $this->error = $this->db->error();
+ return -1;
+ }
+ }
- /**
- * Sets the supplier price expression
- *
- * @param int $expression_id Expression
- * @return int <0 if KO, >0 if OK
- */
- public function setSupplierPriceExpression($expression_id)
- {
- global $conf;
+ /**
+ * Sets the supplier price expression
+ *
+ * @param int $expression_id Expression
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setSupplierPriceExpression($expression_id)
+ {
+ global $conf;
- // Clean parameters
- $this->db->begin();
- $expression_id = $expression_id != 0 ? $expression_id : 'NULL';
+ // Clean parameters
+ $this->db->begin();
+ $expression_id = $expression_id != 0 ? $expression_id : 'NULL';
- $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
- $sql .= " SET fk_supplier_price_expression = ".$expression_id;
- $sql .= " WHERE rowid = ".$this->product_fourn_price_id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
+ $sql .= " SET fk_supplier_price_expression = ".$expression_id;
+ $sql .= " WHERE rowid = ".$this->product_fourn_price_id;
- dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG);
+ dol_syslog(get_class($this)."::setSupplierPriceExpression", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->error()." sql=".$sql;
- $this->db->rollback();
- return -1;
- }
- }
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->error = $this->db->error()." sql=".$sql;
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Display supplier of product
- *
- * @param int $withpicto Add picto
- * @param string $option Target of link ('', 'customer', 'prospect', 'supplier')
- * @param int $maxlen Max length of name
- * @param integer $notooltip 1=Disable tooltip
- * @return string String with supplier price
+ /**
+ * Display supplier of product
+ *
+ * @param int $withpicto Add picto
+ * @param string $option Target of link ('', 'customer', 'prospect', 'supplier')
+ * @param int $maxlen Max length of name
+ * @param integer $notooltip 1=Disable tooltip
+ * @return string String with supplier price
* TODO Remove this method. Use getNomUrl directly.
- */
- public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0)
- {
- $thirdparty = new Fournisseur($this->db);
- $thirdparty->fetch($this->fourn_id);
+ */
+ public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0)
+ {
+ $thirdparty = new Fournisseur($this->db);
+ $thirdparty->fetch($this->fourn_id);
- return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip);
- }
+ return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip);
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Display price of product
- *
- * @param int $showunitprice Show "Unit price" into output string
- * @param int $showsuptitle Show "Supplier" into output string
- * @param int $maxlen Max length of name
- * @param integer $notooltip 1=Disable tooltip
- * @param array $productFournList list of ProductFournisseur objects
- * to display in table format.
- * @return string String with supplier price
- */
- public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())
- {
- // phpcs:enable
- global $langs;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Display price of product
+ *
+ * @param int $showunitprice Show "Unit price" into output string
+ * @param int $showsuptitle Show "Supplier" into output string
+ * @param int $maxlen Max length of name
+ * @param integer $notooltip 1=Disable tooltip
+ * @param array $productFournList list of ProductFournisseur objects
+ * to display in table format.
+ * @return string String with supplier price
+ */
+ public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())
+ {
+ // phpcs:enable
+ global $langs;
- $out = '';
- $langs->load("suppliers");
- if (count($productFournList) > 0) {
- $out .= '';
- $out .= '| '.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').' | ';
- $out .= ''.($showunitprice ? $langs->trans("QtyMin") : '').' | ';
- $out .= ''.$langs->trans("Supplier").' | ';
- $out .= ''.$langs->trans("SupplierRef").' | ';
- foreach ($productFournList as $productFourn) {
- $out .= '| '.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').' | ';
- $out .= ''.($showunitprice ? $productFourn->fourn_qty : '').' | ';
- $out .= ''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' | ';
- $out .= ''.$productFourn->fourn_ref.' | | ';
- }
- $out .= ' ';
- } else {
- $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : '');
- }
- return $out;
- }
+ $out = '';
+ $langs->load("suppliers");
+ if (count($productFournList) > 0) {
+ $out .= '';
+ $out .= '| '.($showunitprice ? $langs->trans("Price").' '.$langs->trans("HT") : '').' | ';
+ $out .= ''.($showunitprice ? $langs->trans("QtyMin") : '').' | ';
+ $out .= ''.$langs->trans("Supplier").' | ';
+ $out .= ''.$langs->trans("SupplierRef").' | ';
+ foreach ($productFournList as $productFourn) {
+ $out .= '| '.($showunitprice ?price($productFourn->fourn_unitprice * (1 - $productFourn->fourn_remise_percent / 100) - $productFourn->fourn_remise) : '').' | ';
+ $out .= ''.($showunitprice ? $productFourn->fourn_qty : '').' | ';
+ $out .= ''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' | ';
+ $out .= ''.$productFourn->fourn_ref.' | | ';
+ }
+ $out .= ' ';
+ } else {
+ $out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : '');
+ }
+ return $out;
+ }
- /**
- * Function used to replace a thirdparty id with another one.
- *
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
- * @return bool
- */
- public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
- {
- $tables = array(
- 'product_fournisseur_price'
- );
+ /**
+ * Function used to replace a thirdparty id with another one.
+ *
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
+ * @return bool
+ */
+ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
+ {
+ $tables = array(
+ 'product_fournisseur_price'
+ );
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
- }
+ return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
+ }
- /**
- * List supplier prices log of a supplier price
- *
- * @param int $product_fourn_price_id Id of supplier price
- * @param string $sortfield Sort field
- * @param string $sortorder Sort order
- * @param int $limit Limit
- * @param int $offset Offset
- * @return array Array of Log prices
- */
- public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)
- {
- $sql = "SELECT";
- $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
- $sql .= " pfpl.price, pfpl.quantity";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl";
- $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
- $sql .= ", ".MAIN_DB_PREFIX."user as u";
- $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")";
- $sql .= " AND pfpl.fk_user = u.rowid";
- $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur";
- $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id;
- if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec";
- else $sql .= $this->db->order($sortfield, $sortorder);
- $sql .= $this->db->plimit($limit, $offset);
- dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG);
+ /**
+ * List supplier prices log of a supplier price
+ *
+ * @param int $product_fourn_price_id Id of supplier price
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Limit
+ * @param int $offset Offset
+ * @return array Array of Log prices
+ */
+ public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0)
+ {
+ $sql = "SELECT";
+ $sql .= " pfpl.rowid, pfp.ref_fourn as supplier_ref, pfpl.datec, u.lastname,";
+ $sql .= " pfpl.price, pfpl.quantity";
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price_log as pfpl";
+ $sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
+ $sql .= ", ".MAIN_DB_PREFIX."user as u";
+ $sql .= " WHERE pfp.entity IN (".getEntity('productprice').")";
+ $sql .= " AND pfpl.fk_user = u.rowid";
+ $sql .= " AND pfp.rowid = pfpl.fk_product_fournisseur";
+ $sql .= " AND pfpl.fk_product_fournisseur = ".$product_fourn_price_id;
+ if (empty($sortfield)) $sql .= " ORDER BY pfpl.datec";
+ else $sql .= $this->db->order($sortfield, $sortorder);
+ $sql .= $this->db->plimit($limit, $offset);
+ dol_syslog(get_class($this)."::list_product_fournisseur_price_log", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $retarray = array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $retarray = array();
- while ($obj = $this->db->fetch_object($resql))
- {
- $tmparray = array();
- $tmparray['rowid'] = $obj->rowid;
- $tmparray['supplier_ref'] = $obj->supplier_ref;
- $tmparray['datec'] = $this->db->jdate($obj->datec);
- $tmparray['lastname'] = $obj->lastname;
- $tmparray['price'] = $obj->price;
- $tmparray['quantity'] = $obj->quantity;
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $tmparray = array();
+ $tmparray['rowid'] = $obj->rowid;
+ $tmparray['supplier_ref'] = $obj->supplier_ref;
+ $tmparray['datec'] = $this->db->jdate($obj->datec);
+ $tmparray['lastname'] = $obj->lastname;
+ $tmparray['price'] = $obj->price;
+ $tmparray['quantity'] = $obj->quantity;
- $retarray[] = $tmparray;
- }
+ $retarray[] = $tmparray;
+ }
- $this->db->free($resql);
- return $retarray;
- } else {
- $this->error = $this->db->error();
- return -1;
- }
- }
+ $this->db->free($resql);
+ return $retarray;
+ } else {
+ $this->error = $this->db->error();
+ return -1;
+ }
+ }
- /**
- * Display log price of product supplier price
- *
- * @param array $productFournLogList list of ProductFournisseur price log objects
- * to display in table format.
- * @return string HTML String with supplier price
- */
- public function displayPriceProductFournisseurLog($productFournLogList = array())
- {
- global $langs;
+ /**
+ * Display log price of product supplier price
+ *
+ * @param array $productFournLogList list of ProductFournisseur price log objects
+ * to display in table format.
+ * @return string HTML String with supplier price
+ */
+ public function displayPriceProductFournisseurLog($productFournLogList = array())
+ {
+ global $langs;
- $out = '';
- $langs->load("suppliers");
- if (count($productFournLogList) > 0) {
- $out .= '';
- $out .= '| '.$langs->trans("Date").' | ';
- $out .= ''.$langs->trans("Price").' | ';
- //$out .= ''.$langs->trans("QtyMin").' | ';
- $out .= ''.$langs->trans("User").' | ';
- foreach ($productFournLogList as $productFournLog) {
- $out .= '| '.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').' | ';
- $out .= ''.price($productFournLog['price']).' | ';
- //$out.= ''.$productFournLog['quantity'].' | ';
- $out .= ''.$productFournLog['lastname'].' | ';
- }
- $out .= ' ';
- }
- return $out;
- }
+ $out = '';
+ $langs->load("suppliers");
+ if (count($productFournLogList) > 0) {
+ $out .= '';
+ $out .= '| '.$langs->trans("Date").' | ';
+ $out .= ''.$langs->trans("Price").' | ';
+ //$out .= ''.$langs->trans("QtyMin").' | ';
+ $out .= ''.$langs->trans("User").' | ';
+ foreach ($productFournLogList as $productFournLog) {
+ $out .= '| '.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').' | ';
+ $out .= ''.price($productFournLog['price']).' | ';
+ //$out.= ''.$productFournLog['quantity'].' | ';
+ $out .= ''.$productFournLog['lastname'].' | ';
+ }
+ $out .= ' ';
+ }
+ return $out;
+ }
- /**
- * Return a link to the object card (with optionaly the picto).
- * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl().
- *
- * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
- * @param string $option On what the link point to ('nolink', ...)
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
- {
- global $db, $conf, $langs;
+ /**
+ * Return a link to the object card (with optionaly the picto).
+ * Used getNomUrl of ProductFournisseur if a specific supplier ref is loaded. Otherwise use Product->getNomUrl().
+ *
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $db, $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("SupplierRef").'';
- $label .= ' ';
- $label .= ''.$langs->trans('Product').': '.$this->ref;
- $label .= ' '.$langs->trans('RefSupplier').': '.$this->ref_supplier;
+ $label = ''.$langs->trans("SupplierRef").'';
+ $label .= ' ';
+ $label .= ''.$langs->trans('Product').': '.$this->ref;
+ $label .= ' '.$langs->trans('RefSupplier').': '.$this->ref_supplier;
- $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
- if (is_array($logPrices) && count($logPrices) > 0) {
- $label .= '
';
- $label .= ''.$langs->trans("History").'';
- $label .= $this->displayPriceProductFournisseurLog($logPrices);
- }
+ $logPrices = $this->listProductFournisseurPriceLog($this->product_fourn_price_id, 'pfpl.datec', 'DESC'); // set sort order here
+ if (is_array($logPrices) && count($logPrices) > 0) {
+ $label .= '
';
+ $label .= ''.$langs->trans("History").'';
+ $label .= $this->displayPriceProductFournisseurLog($logPrices);
+ }
- $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id;
+ $url = dol_buildpath('/product/fournisseurs.php', 1).'?id='.$this->id.'&action=add_price&socid='.$this->fourn_id.'&rowid='.$this->product_fourn_price_id;
- if ($option != 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
- }
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ }
- $linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label = $langs->trans("SupplierRef");
- $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ $linkclose = '';
+ if (empty($notooltip))
+ {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label = $langs->trans("SupplierRef");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
- $linkstart = '';
- $linkend = '';
+ $linkstart = '';
+ $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 != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : '');
- $result .= $linkend;
- //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+ $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 != 2) $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : '');
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
- return $result;
- }
+ return $result;
+ }
- /**
- * Private function to log price history
- *
- * @param User $user Object user who adds/changes price
- * @param integer $datec date create
- * @param float $buyprice price for qty
- * @param float $qty qty for price
- * @param float $multicurrency_buyprice Purchase price for the quantity min in currency
- * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency
- * @param float $multicurrency_tx Rate currency
- * @param int $fk_multicurrency key multi currency
- * @param string $multicurrency_code Currency code
- *
- * @return int < 0 NOK > 0 OK
- */
- private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null)
- {
- // Add record into log table
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log(";
- $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
- $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)";
- $sql .= "values(";
- $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
- $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
- $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
- $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
- $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
- $sql .= "'".$this->db->idate($datec)."',";
- $sql .= " ".$this->product_fourn_price_id.",";
- $sql .= " ".$user->id.",";
- $sql .= " ".price2num($buyprice).",";
- $sql .= " ".$qty;
- $sql .= ")";
+ /**
+ * Private function to log price history
+ *
+ * @param User $user Object user who adds/changes price
+ * @param integer $datec date create
+ * @param float $buyprice price for qty
+ * @param float $qty qty for price
+ * @param float $multicurrency_buyprice Purchase price for the quantity min in currency
+ * @param float $multicurrency_unitBuyPrice Unit Purchase price in currency
+ * @param float $multicurrency_tx Rate currency
+ * @param int $fk_multicurrency key multi currency
+ * @param string $multicurrency_code Currency code
+ *
+ * @return int < 0 NOK > 0 OK
+ */
+ private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null)
+ {
+ // Add record into log table
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log(";
+ $sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
+ $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)";
+ $sql .= "values(";
+ $sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
+ $sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
+ $sql .= (isset($multicurrency_tx) ? "'".$this->db->escape($multicurrency_tx)."'" : '1').",";
+ $sql .= (isset($fk_multicurrency) ? "'".$this->db->escape($fk_multicurrency)."'" : 'null').",";
+ $sql .= (isset($multicurrency_code) ? "'".$this->db->escape($multicurrency_code)."'" : 'null').",";
+ $sql .= "'".$this->db->idate($datec)."',";
+ $sql .= " ".$this->product_fourn_price_id.",";
+ $sql .= " ".$user->id.",";
+ $sql .= " ".price2num($buyprice).",";
+ $sql .= " ".$qty;
+ $sql .= ")";
- $resql = $this->db->query($sql);
- if (!$resql) {
- return -1;
- } else {
- return 1;
- }
- }
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
}
diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php
index 67133ed97b2..8689801e543 100644
--- a/htdocs/fourn/class/paiementfourn.class.php
+++ b/htdocs/fourn/class/paiementfourn.class.php
@@ -123,7 +123,7 @@ class PaiementFourn extends Paiement
$this->bank_account = $obj->fk_account;
$this->fk_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
- $this->montant = $obj->amount; // deprecated
+ $this->montant = $obj->amount; // deprecated
$this->amount = $obj->amount;
$this->multicurrency_amount = $obj->multicurrency_amount;
$this->note = $obj->note;
@@ -176,7 +176,7 @@ class PaiementFourn extends Paiement
foreach ($amounts as $key => $value)
{
- $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value? $value : 0, $way, 'facture_fourn');
+ $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value ? $value : 0, $way, 'facture_fourn');
$totalamount_converted += $value_converted;
$amounts_to_update[$key] = price2num($value_converted, 'MT');
@@ -191,7 +191,7 @@ class PaiementFourn extends Paiement
if ($totalamount <> 0) // On accepte les montants negatifs
{
- $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
+ $ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
$now = dol_now();
if ($way == 'dolibarr')
@@ -247,8 +247,8 @@ class PaiementFourn extends Paiement
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $newlang = '';
- $outputlangs = $langs;
+ $newlang = '';
+ $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@@ -491,7 +491,7 @@ class PaiementFourn extends Paiement
return $this->LibStatut($this->statut, $mode);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -501,7 +501,7 @@ class PaiementFourn extends Paiement
*/
public function LibStatut($status, $mode = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $langs;
$langs->load('compta');
@@ -550,7 +550,7 @@ class PaiementFourn extends Paiement
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option Sur quoi pointe le lien
* @param string $mode 'withlistofinvoices'=Include list of invoices into tooltip
- * @param int $notooltip 1=Disable tooltip
+ * @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL
*/
public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0)
@@ -695,7 +695,7 @@ class PaiementFourn extends Paiement
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
+ * @param null|array $moreparams Array to provide more information
* @return int <0 if KO, 0 if nothing done, >0 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
@@ -753,7 +753,7 @@ class PaiementFourn extends Paiement
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load the third party of object, from id into this->thirdparty
*
@@ -762,7 +762,7 @@ class PaiementFourn extends Paiement
*/
public function fetch_thirdparty($force_thirdparty_id = 0)
{
- // phpcs:enable
+ // phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (empty($force_thirdparty_id))
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 46b3d372dfd..b5a0111e4f4 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -110,7 +110,7 @@ if ($id > 0 || !empty($ref))
}
// Common permissions
-$usercanread = $user->rights->fournisseur->commande->lire;
+$usercanread = $user->rights->fournisseur->commande->lire;
$usercancreate = $user->rights->fournisseur->commande->creer;
$usercandelete = $user->rights->fournisseur->commande->supprimer;
@@ -119,14 +119,14 @@ $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($u
// Additional area permissions
$usercanapprove = $user->rights->fournisseur->commande->approuver;
-$usercanapprovesecond = $user->rights->fournisseur->commande->approve2;
-$usercanorder = $user->rights->fournisseur->commande->commander;
+$usercanapprovesecond = $user->rights->fournisseur->commande->approve2;
+$usercanorder = $user->rights->fournisseur->commande->commander;
$usercanreceived = $user->rights->fournisseur->commande->receptionner;
// Permissions for includes
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
-$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
+$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
@@ -872,7 +872,7 @@ if (empty($reshook))
$action = 'confirm_approve'; // can make standard or first level approval also if permission is set
}
- if (! $error) {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -1059,7 +1059,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors');
}
- if (! $error) {
+ if (!$error) {
$db->commit();
} else {
$db->rollback();
@@ -1684,8 +1684,8 @@ if ($action == 'create')
// Incoterms
if (!empty($conf->incoterm->enabled))
{
- $fkincoterms = (!empty($object->fk_incoterms) ? $object->fk_incoterms : ($socid > 0 ? $societe->fk_incoterms : ''));
- $locincoterms = (!empty($object->location_incoterms) ? $object->location_incoterms : ($socid > 0 ? $societe->location_incoterms : ''));
+ $fkincoterms = (!empty($object->fk_incoterms) ? $object->fk_incoterms : ($socid > 0 ? $societe->fk_incoterms : ''));
+ $locincoterms = (!empty($object->location_incoterms) ? $object->location_incoterms : ($socid > 0 ? $societe->location_incoterms : ''));
print '';
print ' | ';
print '';
diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php
index 3dc9a68d814..08a40ad52b8 100644
--- a/htdocs/fourn/commande/contact.php
+++ b/htdocs/fourn/commande/contact.php
@@ -55,11 +55,11 @@ if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer)
{
$result = $object->fetch($id);
- if ($result > 0 && $id > 0)
- {
- $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+ if ($result > 0 && $id > 0)
+ {
+ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
- }
+ }
if ($result >= 0)
{
@@ -81,7 +81,7 @@ elseif ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer)
{
if ($object->fetch($id))
{
- $result = $object->swapContactStatus(GETPOST('ligne'));
+ $result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
@@ -146,36 +146,36 @@ if ($id > 0 || !empty($ref))
// Project
if (!empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->fournisseur->commande->creer)
- {
- if ($action != 'classify') {
- //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $langs->load("projects");
+ $morehtmlref .= ' '.$langs->trans('Project').' ';
+ if ($user->rights->fournisseur->commande->creer)
+ {
+ if ($action != 'classify') {
+ //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= '';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= '';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= '';
- } else {
- $morehtmlref .= '';
- }
- }
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
}
$morehtmlref .= '';
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 8b735f6b6d8..a924ca03270 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
if (!empty($conf->projet->enabled))
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@@ -276,7 +276,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET unitprice='".GETPOST($pu)."'";
$sql .= ", price=".GETPOST($pu)."*quantity";
- $sql .= ", remise_percent='".(!empty($dto)?$dto:0)."'";
+ $sql .= ", remise_percent='".(!empty($dto) ? $dto : 0)."'";
$sql .= " WHERE fk_soc=".$object->socid;
$sql .= " AND fk_product=".GETPOST($prod, 'int');
@@ -348,7 +348,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET unitprice='".GETPOST($pu)."'";
$sql .= ", price=".GETPOST($pu)."*quantity";
- $sql .= ", remise_percent='".(!empty($dto)?$dto:0)."'";
+ $sql .= ", remise_percent='".(!empty($dto) ? $dto : 0)."'";
$sql .= " WHERE fk_soc=".$object->socid;
$sql .= " AND fk_product=".GETPOST($prod, 'int');
@@ -419,16 +419,16 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fourn
}
else {
// If module stock is enabled and the stock increase is done on purchase order dispatching
- if ($entrepot > 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+ if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
{
$mouv = new MouvementStock($db);
if ($product > 0)
{
$mouv->origin = &$object;
- $result=$mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch);
+ $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch);
if ($result < 0)
{
- $errors=$mouv->errors;
+ $errors = $mouv->errors;
$error++;
}
}
@@ -470,28 +470,28 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne
if ($result < 0)
{
$error++;
- $errors=$supplierorderdispatch->errors;
+ $errors = $supplierorderdispatch->errors;
}
else {
// If module stock is enabled and the stock increase is done on purchase order dispatching
- if ($entrepot > 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
+ if ($entrepot > 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
{
$mouv = new MouvementStock($db);
if ($product > 0)
{
$mouv->origin = &$object;
- $result=$mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch);
+ $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch);
if ($result < 0)
{
- $errors=$mouv->errors;
+ $errors = $mouv->errors;
$error++;
}
else {
$mouv->origin = &$object;
- $result=$mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, $eatby, $sellby, $batch);
+ $result = $mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, $eatby, $sellby, $batch);
if ($result < 0)
{
- $errors=$mouv->errors;
+ $errors = $mouv->errors;
$error++;
}
}
@@ -534,20 +534,20 @@ if ($id > 0 || !empty($ref)) {
$title = $langs->trans("SupplierOrder");
print dol_get_fiche_head($head, 'dispatch', $title, -1, 'order');
- $formconfirm='';
+ $formconfirm = '';
// Confirmation to delete line
if ($action == 'ask_deleteline')
{
- $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
}
// Call Hook formConfirm
$parameters = array('lineid' => $lineid);
// Note that $action and $object may be modified by hook
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action);
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
+ if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -652,7 +652,7 @@ if ($id > 0 || !empty($ref)) {
$formproduct = new FormProduct($db);
$formproduct->loadWarehouses();
$entrepot = new Entrepot($db);
- $listwarehouses=$entrepot->list_array(1);
+ $listwarehouses = $entrepot->list_array(1);
if (empty($conf->reception->enabled))print ' | ';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
print '';
- $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year'));
- print $form->selectDate($dlcdatesuffix, 'dlc' . $suffix, '', '', 1, '');
+ $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year'));
+ print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, '');
print ' | ';
}
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
@@ -991,7 +991,7 @@ if ($id > 0 || !empty($ref)) {
// Discount
print '';
- print '';
+ print '';
print ' | ';
// Save price
@@ -1105,11 +1105,11 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT p.rowid as pid, p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.ref as entrepot,";
$sql .= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.datec";
- $sql.=" ,cd.rowid, cd.subprice";
+ $sql .= " ,cd.rowid, cd.subprice";
if ($conf->reception->enabled)$sql .= " ,cfd.fk_reception, r.date_delivery";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
$sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid";
if ($conf->reception->enabled)$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid";
$sql .= " WHERE cfd.fk_commande = ".$object->id;
@@ -1138,10 +1138,10 @@ if ($id > 0 || !empty($ref)) {
if (!empty($conf->productbatch->enabled)) {
print ''.$langs->trans("batch_number").' | ';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
- print '' . $langs->trans("EatByDate") . ' | ';
+ print ''.$langs->trans("EatByDate").' | ';
}
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
- print '' . $langs->trans("SellByDate") . ' | ';
+ print ''.$langs->trans("SellByDate").' | ';
}
}
print ''.$langs->trans("QtyDispatched").' | ';
@@ -1164,7 +1164,7 @@ if ($id > 0 || !empty($ref)) {
if ($action == 'editline' && $lineid == $objp->dispatchlineid)
{
- print '';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= '';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= '';
- } else {
- $morehtmlref .= '';
- }
- }
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
}
$morehtmlref .= '';
diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php
index 6891e3bdf92..1e9e69fb8cd 100644
--- a/htdocs/fourn/commande/index.php
+++ b/htdocs/fourn/commande/index.php
@@ -61,14 +61,14 @@ print '';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
- print ' \n";
+ print ' \n";
}
diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php
index b4fe6714bc9..a50cbbdad39 100644
--- a/htdocs/fourn/commande/info.php
+++ b/htdocs/fourn/commande/info.php
@@ -53,10 +53,10 @@ if (!$sortorder) $sortorder = 'DESC,DESC';
if (GETPOST('actioncode', 'array'))
{
- $actioncode = GETPOST('actioncode', 'array', 3);
- if (!count($actioncode)) $actioncode = '0';
+ $actioncode = GETPOST('actioncode', 'array', 3);
+ if (!count($actioncode)) $actioncode = '0';
} else {
- $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS));
+ $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS));
}
$search_agenda_label = GETPOST('search_agenda_label');
@@ -81,8 +81,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
{
- $actioncode = '';
- $search_agenda_label = '';
+ $actioncode = '';
+ $search_agenda_label = '';
}
@@ -96,9 +96,9 @@ $object = new CommandeFournisseur($db);
if ($id > 0 || !empty($ref))
{
- $object->fetch($id, $ref);
- $object->fetch_thirdparty();
- $object->info($object->id);
+ $object->fetch($id, $ref);
+ $object->fetch_thirdparty();
+ $object->info($object->id);
}
$title = $langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name;
@@ -127,36 +127,36 @@ $morehtmlref .= ' '.$langs->trans('ThirdParty').' : '.$object->thirdparty->ge
// Project
if (!empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->fournisseur->commande->creer)
- {
- if ($action != 'classify') {
- //$morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ' ';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= '';
- } else {
- $morehtmlref .= '';
- }
- }
+ $langs->load("projects");
+ $morehtmlref .= ' '.$langs->trans('Project').' ';
+ if ($user->rights->fournisseur->commande->creer)
+ {
+ if ($action != 'classify') {
+ //$morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref .= ' : ';
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= ' ';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ' ';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
}
$morehtmlref .= ' ';
@@ -183,7 +183,7 @@ $out = '';
$permok = $user->rights->agenda->myactions->create;
if ($permok)
{
- $out .= '&originid='.$object->id.'&origin=order_supplier';
+ $out .= '&originid='.$object->id.'&origin=order_supplier';
}
@@ -191,12 +191,12 @@ print ' ';
@@ -204,27 +204,27 @@ print ' ';
if (!empty($object->id))
{
- $param = '&id='.$object->id;
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+ $param = '&id='.$object->id;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
+ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
- print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
+ print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
- // List of actions on element
- /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+ // List of actions on element
+ /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions=new FormActions($db);
$somethingshown = $formactions->showactions($object,'project',0);*/
- // List of todo actions
- //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
+ // List of todo actions
+ //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
- // List of done actions
- //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
+ // List of done actions
+ //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
- // List of all actions
- $filters = array();
- $filters['search_agenda_label'] = $search_agenda_label;
- show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
+ // List of all actions
+ $filters = array();
+ $filters['search_agenda_label'] = $search_agenda_label;
+ show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
}
// End of page
diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php
index 639ae4a8a69..dea5ad69afa 100644
--- a/htdocs/fourn/commande/note.php
+++ b/htdocs/fourn/commande/note.php
@@ -74,17 +74,17 @@ $now = dol_now();
if ($id > 0 || !empty($ref))
{
- if ($result >= 0)
- {
- $object->fetch_thirdparty();
+ if ($result >= 0)
+ {
+ $object->fetch_thirdparty();
- $author = new User($db);
- $author->fetch($object->user_author_id);
+ $author = new User($db);
+ $author->fetch($object->user_author_id);
- $head = ordersupplier_prepare_head($object);
+ $head = ordersupplier_prepare_head($object);
- $title = $langs->trans("SupplierOrder");
- print dol_get_fiche_head($head, 'note', $title, -1, 'order');
+ $title = $langs->trans("SupplierOrder");
+ print dol_get_fiche_head($head, 'note', $title, -1, 'order');
// Supplier order card
@@ -99,36 +99,36 @@ if ($id > 0 || !empty($ref))
// Project
if (!empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->fournisseur->commande->creer)
- {
- if ($action != 'classify') {
- //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $langs->load("projects");
+ $morehtmlref .= ' '.$langs->trans('Project').' ';
+ if ($user->rights->fournisseur->commande->creer)
+ {
+ if ($action != 'classify') {
+ //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
- }
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= '';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= '';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= '';
- } else {
- $morehtmlref .= '';
- }
- }
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
}
$morehtmlref .= '';
@@ -140,16 +140,16 @@ if ($id > 0 || !empty($ref))
$cssclass = "titlefield";
- include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
+ include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
- print '';
+ print '';
- print dol_get_fiche_end();
- } else {
- /* Order not found */
- $langs->load("errors");
- print $langs->trans("ErrorRecordNotFound");
- }
+ print dol_get_fiche_end();
+ } else {
+ /* Order not found */
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
+ }
}
// End of page
diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
index 375cf10caa2..57dfb90e3fd 100644
--- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php
@@ -39,10 +39,10 @@ $total = 0;
$ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
- $ilink++;
+ $ilink++;
- $trclass = 'oddeven';
- if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
+ $trclass = 'oddeven';
+ if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
?>
| trans("SupplierOrder"); ?> |
@@ -50,10 +50,10 @@ foreach ($linkedObjectBlock as $key => $objectlink)
ref_supplier; ?> |
date, 'day'); ?> |
rights->fournisseur->commande->lire) {
- $total = $total + $objectlink->total_ht;
- echo price($objectlink->total_ht);
- } ?> |
+ if ($user->rights->fournisseur->commande->lire) {
+ $total = $total + $objectlink->total_ht;
+ echo price($objectlink->total_ht);
+ } ?>
getLibStatut(3); ?> |
id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> |
@@ -61,7 +61,7 @@ foreach ($linkedObjectBlock as $key => $objectlink)
}
if (count($linkedObjectBlock) > 1)
{
- ?>
+ ?>
| trans("Total"); ?> |
|
diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php
index edcccbc6a88..781fd4b6e9a 100644
--- a/htdocs/fourn/contact.php
+++ b/htdocs/fourn/contact.php
@@ -37,8 +37,8 @@ llxHeader();
// Security check
if ($user->socid > 0)
{
- $action = '';
- $socid = $user->socid;
+ $action = '';
+ $socid = $user->socid;
}
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@@ -69,21 +69,21 @@ $sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (dol_strlen($stcomm)) {
- $sql .= " AND s.fk_stcomm=$stcomm";
+ $sql .= " AND s.fk_stcomm=$stcomm";
}
if (dol_strlen($begin)) {
- $sql .= " AND p.name LIKE '$begin%'";
+ $sql .= " AND p.name LIKE '$begin%'";
}
if ($contactname) {
- $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'";
- $sortfield = "p.name";
- $sortorder = "ASC";
+ $sql .= " AND p.name LIKE '%".strtolower($contactname)."%'";
+ $sortfield = "p.name";
+ $sortorder = "ASC";
}
if ($socid) {
- $sql .= " AND s.rowid = ".$socid;
+ $sql .= " AND s.rowid = ".$socid;
}
$sql .= " ORDER BY $sortfield $sortorder ";
@@ -92,40 +92,40 @@ $sql .= $db->plimit($limit, $offset);
$result = $db->query($sql);
if ($result)
{
- $num = $db->num_rows($result);
+ $num = $db->num_rows($result);
- $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
- print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
+ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses"));
+ print_barre_liste($title." (".$langs->trans("Suppliers").")", $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
- print '';
- print '';
- print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, "", "", $sortfield, $sortorder);
- print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder);
- print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder);
- print_liste_field_titre("Email");
- print_liste_field_titre("Phone");
- print " \n";
+ print '';
+ print '';
+ print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "p.name", $begin, "", "", $sortfield, $sortorder);
+ print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "p.firstname", $begin, "", "", $sortfield, $sortorder);
+ print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", $begin, "", "", $sortfield, $sortorder);
+ print_liste_field_titre("Email");
+ print_liste_field_titre("Phone");
+ print " \n";
- $i = 0;
- while ($i < min($num, $limit))
- {
- $obj = $db->fetch_object($result);
+ $i = 0;
+ while ($i < min($num, $limit))
+ {
+ $obj = $db->fetch_object($result);
- print '';
+ print ' ';
- print '| '.img_object($langs->trans("ShowContact"), "contact").' '.$obj->lastname.' | ';
- print ''.$obj->firstname.' | ';
- print ''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.' | ';
- print ''.$obj->email.' | ';
- print ''.$obj->phone.' | ';
+ print ''.img_object($langs->trans("ShowContact"), "contact").' '.$obj->lastname.' | ';
+ print ''.$obj->firstname.' | ';
+ print ''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.' | ';
+ print ''.$obj->email.' | ';
+ print ''.$obj->phone.' | ';
- print " \n";
- $i++;
- }
- print " ";
- $db->free($result);
+ print "\n";
+ $i++;
+ }
+ print " ";
+ $db->free($result);
} else {
- dol_print_error($db);
+ dol_print_error($db);
}
// End of page
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 557e6c56d3b..a632320a87e 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -101,18 +101,18 @@ $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', 'rowid', $isdraft);
// Common permissions
-$usercanread = $user->rights->fournisseur->facture->lire;
+$usercanread = $user->rights->fournisseur->facture->lire;
$usercancreate = $user->rights->fournisseur->facture->creer;
$usercandelete = $user->rights->fournisseur->facture->supprimer;
// Advanced permissions
-$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)));
-$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send);
+$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)));
+$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send);
// Permissions for includes
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
-$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
+$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
+$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
@@ -227,7 +227,7 @@ if (empty($reshook))
$isErasable = $object->is_erasable();
- if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1))
+ if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1))
{
$result = $object->delete($user);
if ($result > 0)
@@ -325,7 +325,7 @@ if (empty($reshook))
$db->begin();
- if (! $error) {
+ if (!$error) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) {
$error++;
@@ -333,7 +333,7 @@ if (empty($reshook))
}
}
- if (! $error) {
+ if (!$error) {
$old_date_echeance = $object->date_echeance;
$new_date_echeance = $object->calculate_date_lim_reglement();
if ($new_date_echeance > $old_date_echeance) $object->date_echeance = $new_date_echeance;
@@ -382,7 +382,7 @@ if (empty($reshook))
// transport mode
if ($action == 'settransportmode' && $user->rights->fournisseur->facture->creer)
{
- $result=$object->setTransportMode(GETPOST('transport_mode_id', 'int'));
+ $result = $object->setTransportMode(GETPOST('transport_mode_id', 'int'));
}
// Set label
@@ -698,7 +698,7 @@ if (empty($reshook))
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
- $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
+ $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->transport_mode_id = GETPOST('transport_mode_id', 'int');
// Proprietes particulieres a facture de remplacement
@@ -764,7 +764,7 @@ if (empty($reshook))
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
- $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
+ $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->transport_mode_id = GETPOST('transport_mode_id', 'int');
// Proprietes particulieres a facture avoir
@@ -878,7 +878,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
- $object->transport_mode_id = GETPOST('transport_mode_id');
+ $object->transport_mode_id = GETPOST('transport_mode_id');
// Auto calculation of date due if not filled by user
if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
@@ -1728,7 +1728,7 @@ if ($action == 'create')
$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '';
- $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0));
+ $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0));
if (!empty($conf->multicurrency->enabled))
{
@@ -1747,7 +1747,7 @@ if ($action == 'create')
} else {
$cond_reglement_id = $societe->cond_reglement_supplier_id;
$mode_reglement_id = $societe->mode_reglement_supplier_id;
- $transport_mode_id = $societe->transport_mode_supplier_id;
+ $transport_mode_id = $societe->transport_mode_supplier_id;
$fk_account = $societe->fk_account;
$datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp);
@@ -1767,8 +1767,8 @@ if ($action == 'create')
$mode_reglement_id = GETPOST("mode_reglement_id");
}
- $note_public = $object->getDefaultCreateValueFor('note_public', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_public:null));
- $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_private:null));
+ $note_public = $object->getDefaultCreateValueFor('note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null));
+ $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null));
print ' ';
}
// Other attributes
diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php
index 420d7e3709f..83f145c4c6b 100644
--- a/htdocs/fourn/facture/contact.php
+++ b/htdocs/fourn/facture/contact.php
@@ -55,11 +55,11 @@ if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer)
{
$result = $object->fetch($id, $ref);
- if ($result > 0 && $id > 0)
- {
- $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
+ if ($result > 0 && $id > 0)
+ {
+ $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
$result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
- }
+ }
if ($result >= 0)
{
@@ -81,7 +81,7 @@ elseif ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer)
{
if ($object->fetch($id))
{
- $result = $object->swapContactStatus(GETPOST('ligne'));
+ $result = $object->swapContactStatus(GETPOST('ligne'));
} else {
dol_print_error($db);
}
@@ -138,13 +138,13 @@ if ($id > 0 || !empty($ref))
$linkback = ''.$langs->trans("BackToList").'';
$morehtmlref = '';
- // Ref supplier
- $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref .= ' '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
- if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ( '.$langs->trans("OtherBills").')';
- // Project
+ // Ref supplier
+ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref .= ' '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ( '.$langs->trans("OtherBills").')';
+ // Project
if (!empty($conf->projet->enabled))
{
$langs->load("projects");
@@ -232,25 +232,25 @@ if ($id > 0 || !empty($ref))
print $form->editfieldval("Label", 'label', $object->label, $object, 0);
print '';
- // Amount
- print ' | '.$langs->trans('AmountHT').' | '.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).' | ';
- print ' | '.$langs->trans('AmountVAT').' | '.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).' | ';
+ // Amount
+ print ' | '.$langs->trans('AmountHT').' | '.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).' | ';
+ print ' | '.$langs->trans('AmountVAT').' | '.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).' | ';
- // Amount Local Taxes
- //TODO: Place into a function to control showing by country or study better option
- if ($societe->localtax1_assuj == "1") //Localtax1
- {
- print ' | '.$langs->transcountry("AmountLT1", $societe->country_code).' | ';
- print ''.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).' | ';
- print ' ';
- }
- if ($societe->localtax2_assuj == "1") //Localtax2
- {
- print ' | '.$langs->transcountry("AmountLT2", $societe->country_code).' | ';
- print ''.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).' | ';
- print ' ';
- }
- print ' | '.$langs->trans('AmountTTC').' | '.price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).' | ';
+ // Amount Local Taxes
+ //TODO: Place into a function to control showing by country or study better option
+ if ($societe->localtax1_assuj == "1") //Localtax1
+ {
+ print ' | '.$langs->transcountry("AmountLT1", $societe->country_code).' | ';
+ print ''.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).' | ';
+ print ' ';
+ }
+ if ($societe->localtax2_assuj == "1") //Localtax2
+ {
+ print ' | '.$langs->transcountry("AmountLT2", $societe->country_code).' | ';
+ print ''.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).' | ';
+ print ' ';
+ }
+ print ' | '.$langs->trans('AmountTTC').' | '.price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).' | ';
print " ";
diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php
index 804a78079d3..18c4bff9036 100644
--- a/htdocs/fourn/facture/impayees.php
+++ b/htdocs/fourn/facture/impayees.php
@@ -175,7 +175,7 @@ if ($user->rights->fournisseur->facture->lire)
$titre = ($socid ? $langs->trans("BillsSuppliersUnpaidForCompany", $soc->name) : $langs->trans("BillsSuppliersUnpaid"));
if ($option == 'late') $titre .= ' ('.$langs->trans("Late").')';
- else $titre .= ' ('.$langs->trans("All").')';
+ else $titre .= ' ('.$langs->trans("All").')';
$link = '';
if (empty($option)) $link = ''.$langs->trans("ShowUnpaidLateOnly").'';
@@ -214,10 +214,10 @@ if ($user->rights->fournisseur->facture->lire)
print '';
print '';
print ' | ';
- print '';
- $searchpicto = $form->showFilterAndCheckAddButtons(0);
- print $searchpicto;
- print ' | ';
+ print '';
+ $searchpicto = $form->showFilterAndCheckAddButtons(0);
+ print $searchpicto;
+ print ' | ';
print "\n";
if ($num > 0)
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index c3272544371..3c223ce0837 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -41,9 +41,9 @@ if (isset($user->socid) && $user->socid > 0)
}
// Maximum elements of the tables
-$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
-$maxLatestEditCount = 5;
-$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
+$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
+$maxLatestEditCount = 5;
+$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
/*
* View
@@ -265,11 +265,11 @@ function getDraftTable($maxCount = 500, $socid = 0)
return $result;
}
- $objectstatic = new FactureFournisseur($db);
- $companystatic = new Societe($db);
- $nbofloop = min($num, $maxCount);
- $total = 0;
- $i = 0;
+ $objectstatic = new FactureFournisseur($db);
+ $companystatic = new Societe($db);
+ $nbofloop = min($num, $maxCount);
+ $total = 0;
+ $i = 0;
while ($i < $nbofloop)
{
@@ -357,10 +357,10 @@ function getLatestEditTable($maxCount = 5, $socid = 0)
return $result;
}
- $objectstatic = new FactureFournisseur($db);
- $companystatic = new Societe($db);
- $formfile = new FormFile($db);
- $i = 0;
+ $objectstatic = new FactureFournisseur($db);
+ $companystatic = new Societe($db);
+ $formfile = new FormFile($db);
+ $i = 0;
while ($i < $num)
{
@@ -459,13 +459,13 @@ function getOpenTable($maxCount = 500, $socid = 0)
return $result;
}
- $objectstatic = new FactureFournisseur($db);
- $companystatic = new Societe($db);
+ $objectstatic = new FactureFournisseur($db);
+ $companystatic = new Societe($db);
$formfile = new FormFile($db);
$nbofloop = min($num, $maxCount);
- $now = dol_now();
- $total = 0;
- $i = 0;
+ $now = dol_now();
+ $total = 0;
+ $i = 0;
while ($i < $nbofloop)
{
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index ff2da87d716..06b12e3afaa 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -505,7 +505,7 @@ if ($resql)
'validate'=>$langs->trans("Validate"),
'generate_doc'=>$langs->trans("ReGeneratePDF"),
//'builddoc'=>$langs->trans("PDFMerge"),
- //'presend'=>$langs->trans("SendByMail"),
+ //'presend'=>$langs->trans("SendByMail"),
);
//if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
@@ -653,7 +653,7 @@ if ($resql)
FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
);
- /*
+ /*
if (! empty($conf->global->INVOICE_USE_SITUATION))
{
$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
@@ -969,12 +969,12 @@ if ($resql)
$facturestatic->type = $obj->type;
- //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
- if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
- if ($facturestatic->isCreditNoteUsed()) {
- $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
- }
- }
+ //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice
+ if ($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) {
+ if ($facturestatic->isCreditNoteUsed()) {
+ $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
+ }
+ }
print '';
if (!empty($arrayfields['f.ref']['checked']))
@@ -1308,16 +1308,16 @@ if ($resql)
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
- // Show list of available documents
- $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource .= str_replace('&', '&', $param);
+ // Show list of available documents
+ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource .= str_replace('&', '&', $param);
- $filedir = $diroutputmassaction;
- $genallowed = $user->rights->facture->lire;
- $delallowed = $user->rights->facture->creer;
- $title = '';
+ $filedir = $diroutputmassaction;
+ $genallowed = $user->rights->facture->lire;
+ $delallowed = $user->rights->facture->creer;
+ $title = '';
- print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
+ print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
} else {
dol_print_error($db);
}
diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php
index 33361da57d0..c72e7b72710 100644
--- a/htdocs/fourn/facture/note.php
+++ b/htdocs/fourn/facture/note.php
@@ -86,61 +86,61 @@ if ($object->id > 0)
// Supplier invoice card
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
- $morehtmlref = '';
- // Ref supplier
- $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
- // Thirdparty
- $morehtmlref .= ' '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
- if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ( '.$langs->trans("OtherBills").')';
- // Project
- if (!empty($conf->projet->enabled))
- {
- $langs->load("projects");
- $morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->fournisseur->commande->creer)
- {
- if ($action != 'classify') {
- // $morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref = ' ';
+ // Ref supplier
+ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
+ // Thirdparty
+ $morehtmlref .= ' '.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ( '.$langs->trans("OtherBills").')';
+ // Project
+ if (!empty($conf->projet->enabled))
+ {
+ $langs->load("projects");
+ $morehtmlref .= ' '.$langs->trans('Project').' ';
+ if ($user->rights->fournisseur->commande->creer)
+ {
+ if ($action != 'classify') {
+ // $morehtmlref.=' ' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
}
if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref .= ' ';
- } else {
- $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (!empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref .= ' ';
- $morehtmlref .= $proj->ref;
- $morehtmlref .= '';
- } else {
- $morehtmlref .= '';
- }
- }
- }
- $morehtmlref .= ' ';
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= ' ';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= ' ';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }
+ $morehtmlref .= ' ';
- $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
+ $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
- print '';
- print ' ';
+ print ' ';
+ print ' ';
print ' ';
- // Type
+ // Type
print '| '.$langs->trans('Type').' | ';
print $object->getLibType();
if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
@@ -208,7 +208,7 @@ if ($object->id > 0)
print ' ';
- print '';
+ print '';
$cssclass = "titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index 0f2959b7bd4..c94a1f95272 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -80,7 +80,7 @@ $multicurrency_amountsresttopay = array();
// Security check
if ($user->socid > 0)
{
- $socid = $user->socid;
+ $socid = $user->socid;
}
$object = new PaiementFourn($db);
@@ -104,16 +104,16 @@ $arrayfields = array();
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
- $search_ref = "";
- $search_account = "";
- $search_amount = "";
- $search_paymenttype = "";
- $search_payment_num = "";
- $search_company = "";
- $day = '';
- $year = '';
- $month = '';
- $search_array_options = array();
+ $search_ref = "";
+ $search_account = "";
+ $search_amount = "";
+ $search_paymenttype = "";
+ $search_payment_num = "";
+ $search_company = "";
+ $day = '';
+ $year = '';
+ $month = '';
+ $search_array_options = array();
}
$parameters = array('socid'=>$socid);
@@ -124,115 +124,115 @@ if (empty($reshook))
{
if ($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes'))
{
- $error = 0;
+ $error = 0;
- $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
- $paiement_id = 0;
- $totalpayment = 0;
+ $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
+ $paiement_id = 0;
+ $totalpayment = 0;
$atleastonepaymentnotnull = 0;
$multicurrency_totalpayment = 0;
- // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
- $tmpinvoice = new FactureFournisseur($db);
- foreach ($_POST as $key => $value)
- {
- if (substr($key, 0, 7) == 'amount_')
- {
- $cursorfacid = substr($key, 7);
- $amounts[$cursorfacid] = price2num(GETPOST($key));
- if (!empty($amounts[$cursorfacid])) {
- $atleastonepaymentnotnull++;
- if (is_numeric($amounts[$cursorfacid])) {
- $totalpayment = $totalpayment + $amounts[$cursorfacid];
- } else {
- setEventMessages($langs->transnoentities("InputValueIsNotAnNumber", GETPOST($key)), null, 'warnings');
- }
- }
- $result = $tmpinvoice->fetch($cursorfacid);
- if ($result <= 0) dol_print_error($db);
- $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
- if ($amounts[$cursorfacid])
- {
- // Check amount
- if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
- {
- $addwarning = 1;
- $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
- }
- // Check date
- if ($datepaye && ($datepaye < $tmpinvoice->date))
- {
- $langs->load("errors");
- //$error++;
- setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
- }
- }
+ // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
+ $tmpinvoice = new FactureFournisseur($db);
+ foreach ($_POST as $key => $value)
+ {
+ if (substr($key, 0, 7) == 'amount_')
+ {
+ $cursorfacid = substr($key, 7);
+ $amounts[$cursorfacid] = price2num(GETPOST($key));
+ if (!empty($amounts[$cursorfacid])) {
+ $atleastonepaymentnotnull++;
+ if (is_numeric($amounts[$cursorfacid])) {
+ $totalpayment = $totalpayment + $amounts[$cursorfacid];
+ } else {
+ setEventMessages($langs->transnoentities("InputValueIsNotAnNumber", GETPOST($key)), null, 'warnings');
+ }
+ }
+ $result = $tmpinvoice->fetch($cursorfacid);
+ if ($result <= 0) dol_print_error($db);
+ $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
+ if ($amounts[$cursorfacid])
+ {
+ // Check amount
+ if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid])))
+ {
+ $addwarning = 1;
+ $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
+ }
+ // Check date
+ if ($datepaye && ($datepaye < $tmpinvoice->date))
+ {
+ $langs->load("errors");
+ //$error++;
+ setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
+ }
+ }
- $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]);
- } elseif (substr($key, 0, 21) == 'multicurrency_amount_')
+ $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => $_POST[$key]);
+ } elseif (substr($key, 0, 21) == 'multicurrency_amount_')
{
$cursorfacid = substr($key, 21);
- $multicurrency_amounts[$cursorfacid] = (GETPOST($key) ? price2num(GETPOST($key)) : 0);
- $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
- if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
- $result = $tmpinvoice->fetch($cursorfacid);
- if ($result <= 0) dol_print_error($db);
- $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1));
- if ($multicurrency_amounts[$cursorfacid])
- {
- // Check amount
- if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid])))
- {
- $addwarning = 1;
- $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
- }
- // Check date
- if ($datepaye && ($datepaye < $tmpinvoice->date))
- {
- $langs->load("errors");
- //$error++;
- setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
- }
- }
+ $multicurrency_amounts[$cursorfacid] = (GETPOST($key) ? price2num(GETPOST($key)) : 0);
+ $multicurrency_totalpayment += $multicurrency_amounts[$cursorfacid];
+ if (!empty($multicurrency_amounts[$cursorfacid])) $atleastonepaymentnotnull++;
+ $result = $tmpinvoice->fetch($cursorfacid);
+ if ($result <= 0) dol_print_error($db);
+ $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1));
+ if ($multicurrency_amounts[$cursorfacid])
+ {
+ // Check amount
+ if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid])))
+ {
+ $addwarning = 1;
+ $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPaySupplier")).' '.$langs->trans("HelpPaymentHigherThanReminderToPaySupplier");
+ }
+ // Check date
+ if ($datepaye && ($datepaye < $tmpinvoice->date))
+ {
+ $langs->load("errors");
+ //$error++;
+ setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
+ }
+ }
- $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
+ $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
}
- }
+ }
- // Check parameters
- if ($_POST['paiementid'] <= 0)
- {
- setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
- $error++;
- }
+ // Check parameters
+ if ($_POST['paiementid'] <= 0)
+ {
+ setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
+ $error++;
+ }
- if (!empty($conf->banque->enabled))
- {
- // If bank module is on, account is required to enter a payment
- if (GETPOST('accountid') <= 0)
- {
- setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
- $error++;
- }
- }
+ if (!empty($conf->banque->enabled))
+ {
+ // If bank module is on, account is required to enter a payment
+ if (GETPOST('accountid') <= 0)
+ {
+ setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
+ $error++;
+ }
+ }
- if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull))
- {
- setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
- $error++;
- }
+ if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull))
+ {
+ setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
+ $error++;
+ }
- if (empty($datepaye))
- {
- setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
- $error++;
- }
+ if (empty($datepaye))
+ {
+ setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
+ $error++;
+ }
// Check if payments in both currency
if ($totalpayment > 0 && $multicurrency_totalpayment > 0)
{
setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
- $error++;
+ $error++;
}
}
@@ -241,11 +241,11 @@ if (empty($reshook))
*/
if ($action == 'add_paiement')
{
- if ($error)
- {
- $action = 'create';
- }
- // All the next of this action is displayed at the page's bottom.
+ if ($error)
+ {
+ $action = 'create';
+ }
+ // All the next of this action is displayed at the page's bottom.
}
@@ -254,99 +254,99 @@ if (empty($reshook))
*/
if ($action == 'confirm_paiement' && $confirm == 'yes')
{
- $error = 0;
+ $error = 0;
- $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+ $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
- // Clean parameters amount if payment is for a credit note
- foreach ($amounts as $key => $value) // How payment is dispatched
- {
- $tmpinvoice = new FactureFournisseur($db);
- $tmpinvoice->fetch($key);
- if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
- {
- $newvalue = price2num($value, 'MT');
- $amounts[$key] = - abs($newvalue);
- }
- }
+ // Clean parameters amount if payment is for a credit note
+ foreach ($amounts as $key => $value) // How payment is dispatched
+ {
+ $tmpinvoice = new FactureFournisseur($db);
+ $tmpinvoice->fetch($key);
+ if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
+ {
+ $newvalue = price2num($value, 'MT');
+ $amounts[$key] = - abs($newvalue);
+ }
+ }
- foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched
- {
- $tmpinvoice = new FactureFournisseur($db);
- $tmpinvoice->fetch($key);
- if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
- {
- $newvalue = price2num($value, 'MT');
- $multicurrency_amounts[$key] = - abs($newvalue);
- }
- }
+ foreach ($multicurrency_amounts as $key => $value) // How payment is dispatched
+ {
+ $tmpinvoice = new FactureFournisseur($db);
+ $tmpinvoice->fetch($key);
+ if ($tmpinvoice->type == FactureFournisseur::TYPE_CREDIT_NOTE)
+ {
+ $newvalue = price2num($value, 'MT');
+ $multicurrency_amounts[$key] = - abs($newvalue);
+ }
+ }
//var_dump($amounts);
- //var_dump($multicurrency_amounts);
- //exit;
+ //var_dump($multicurrency_amounts);
+ //exit;
- if (!$error)
- {
- $db->begin();
+ if (!$error)
+ {
+ $db->begin();
- $thirdparty = new Societe($db);
- if ($socid > 0) $thirdparty->fetch($socid);
+ $thirdparty = new Societe($db);
+ if ($socid > 0) $thirdparty->fetch($socid);
- // Creation of payment line
- $paiement = new PaiementFourn($db);
- $paiement->datepaye = $datepaye;
- $paiement->amounts = $amounts; // Array of amounts
- $paiement->multicurrency_amounts = $multicurrency_amounts;
- $paiement->paiementid = GETPOST('paiementid', 'int');
+ // Creation of payment line
+ $paiement = new PaiementFourn($db);
+ $paiement->datepaye = $datepaye;
+ $paiement->amounts = $amounts; // Array of amounts
+ $paiement->multicurrency_amounts = $multicurrency_amounts;
+ $paiement->paiementid = GETPOST('paiementid', 'int');
- $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml');
- $paiement->note_private = GETPOST('comment', 'alpha');
- $paiement->num_payment = $paiement->num_payment;
- $paiement->note_private = $paiement->note_private;
+ $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml');
+ $paiement->note_private = GETPOST('comment', 'alpha');
+ $paiement->num_payment = $paiement->num_payment;
+ $paiement->note_private = $paiement->note_private;
- if (!$error)
- {
- $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
- if ($paiement_id < 0)
- {
- setEventMessages($paiement->error, $paiement->errors, 'errors');
- $error++;
- }
- }
+ if (!$error)
+ {
+ $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
+ if ($paiement_id < 0)
+ {
+ setEventMessages($paiement->error, $paiement->errors, 'errors');
+ $error++;
+ }
+ }
- if (!$error)
- {
- $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', '');
- if ($result < 0)
- {
- setEventMessages($paiement->error, $paiement->errors, 'errors');
- $error++;
- }
- }
+ if (!$error)
+ {
+ $result = $paiement->addPaymentToBank($user, 'payment_supplier', '(SupplierInvoicePayment)', $accountid, '', '');
+ if ($result < 0)
+ {
+ setEventMessages($paiement->error, $paiement->errors, 'errors');
+ $error++;
+ }
+ }
- if (!$error)
- {
- $db->commit();
+ if (!$error)
+ {
+ $db->commit();
- // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
- $invoiceid = 0;
- foreach ($paiement->amounts as $key => $amount)
- {
- $facid = $key;
- if (is_numeric($amount) && $amount <> 0)
- {
- if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment
- else $invoiceid = $facid;
- }
- }
- if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid;
- else $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id;
- header('Location: '.$loc);
- exit;
- } else {
- $db->rollback();
- }
- }
+ // If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
+ $invoiceid = 0;
+ foreach ($paiement->amounts as $key => $amount)
+ {
+ $facid = $key;
+ if (is_numeric($amount) && $amount <> 0)
+ {
+ if ($invoiceid != 0) $invoiceid = -1; // There is more than one invoice payed by this payment
+ else $invoiceid = $facid;
+ }
+ }
+ if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$invoiceid;
+ else $loc = DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$paiement_id;
+ header('Location: '.$loc);
+ exit;
+ } else {
+ $db->rollback();
+ }
+ }
}
}
@@ -365,36 +365,36 @@ llxHeader('', $langs->trans('ListPayment'));
if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement')
{
- $object = new FactureFournisseur($db);
- $result = $object->fetch($facid);
+ $object = new FactureFournisseur($db);
+ $result = $object->fetch($facid);
- $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
- $dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture);
+ $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+ $dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture);
- $sql = 'SELECT s.nom as name, s.rowid as socid,';
- $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
- if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
- $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
- if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql .= ' WHERE f.fk_soc = s.rowid';
- $sql .= ' AND f.rowid = '.$facid;
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- if ($num)
- {
- $obj = $db->fetch_object($resql);
- $total = $obj->total;
+ $sql = 'SELECT s.nom as name, s.rowid as socid,';
+ $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= ' WHERE f.fk_soc = s.rowid';
+ $sql .= ' AND f.rowid = '.$facid;
+ if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ if ($num)
+ {
+ $obj = $db->fetch_object($resql);
+ $total = $obj->total;
- print load_fiche_titre($langs->trans('DoPayment'));
+ print load_fiche_titre($langs->trans('DoPayment'));
- // Add realtime total information
- if (!empty($conf->use_javascript_ajax))
- {
- print "\n".''."\n";
- }
+ print ' '."\n";
+ }
- print '';
- }
- } else dol_print_error($db);
+ print '';
+ }
+ } else dol_print_error($db);
}
// End of page
diff --git a/htdocs/fourn/facture/rapport.php b/htdocs/fourn/facture/rapport.php
index 1c068e19b7d..9ae7970d7db 100644
--- a/htdocs/fourn/facture/rapport.php
+++ b/htdocs/fourn/facture/rapport.php
@@ -40,8 +40,8 @@ $action = GETPOST('action', 'aZ09');
$socid = 0;
if ($user->socid > 0)
{
- $action = '';
- $socid = $user->socid;
+ $action = '';
+ $socid = $user->socid;
}
$dir = $conf->fournisseur->facture->dir_output.'/payments';
@@ -57,27 +57,27 @@ if (!$year) { $year = date("Y"); }
if ($action == 'builddoc')
{
- $rap = new pdf_paiement_fourn($db);
+ $rap = new pdf_paiement_fourn($db);
- $outputlangs = $langs;
- if (GETPOST('lang_id', 'aZ09'))
- {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
- }
+ $outputlangs = $langs;
+ if (GETPOST('lang_id', 'aZ09'))
+ {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09'));
+ }
- // We save charset_output to restore it because write_file can change it if needed for
- // output format that does not support UTF8.
- $sav_charset_output = $outputlangs->charset_output;
- if ($rap->write_file($dir, GETPOST("remonth", 'int'), GETPOST("reyear", 'int'), $outputlangs) > 0)
- {
- $outputlangs->charset_output = $sav_charset_output;
- } else {
- $outputlangs->charset_output = $sav_charset_output;
- dol_print_error($db, $obj->error);
- }
+ // We save charset_output to restore it because write_file can change it if needed for
+ // output format that does not support UTF8.
+ $sav_charset_output = $outputlangs->charset_output;
+ if ($rap->write_file($dir, GETPOST("remonth", 'int'), GETPOST("reyear", 'int'), $outputlangs) > 0)
+ {
+ $outputlangs->charset_output = $sav_charset_output;
+ } else {
+ $outputlangs->charset_output = $sav_charset_output;
+ dol_print_error($db, $obj->error);
+ }
- $year = GETPOST("reyear", 'int');
+ $year = GETPOST("reyear", 'int');
}
@@ -116,58 +116,58 @@ $linkforyear = array();
$found = 0;
if (is_dir($dir))
{
- $handle = opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file))
- {
- $found = 1;
- $linkforyear[] = $file;
- }
- }
- }
+ $handle = opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle)) !== false)
+ {
+ if (is_dir($dir.'/'.$file) && !preg_match('/^\./', $file) && is_numeric($file))
+ {
+ $found = 1;
+ $linkforyear[] = $file;
+ }
+ }
+ }
}
asort($linkforyear);
foreach ($linkforyear as $cursoryear)
{
- print ''.$cursoryear.' ';
+ print ''.$cursoryear.' ';
}
if ($year)
{
- if (is_dir($dir.'/'.$year))
- {
- $handle = opendir($dir.'/'.$year);
+ if (is_dir($dir.'/'.$year))
+ {
+ $handle = opendir($dir.'/'.$year);
- if ($found) print ' ';
- print ' ';
- print '';
- print '';
- print '| '.$langs->trans("Reporting").' | ';
- print ''.$langs->trans("Size").' | ';
- print ''.$langs->trans("Date").' | ';
- print ' ';
+ if ($found) print ' ';
+ print ' ';
+ print '';
+ print '';
+ print '| '.$langs->trans("Reporting").' | ';
+ print ''.$langs->trans("Size").' | ';
+ print ''.$langs->trans("Date").' | ';
+ print ' ';
- if (is_resource($handle))
- {
- while (($file = readdir($handle)) !== false)
- {
- if (preg_match('/^supplier_payment/i', $file))
- {
- $tfile = $dir.'/'.$year.'/'.$file;
- $relativepath = $year.'/'.$file;
- print '| '.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_fournisseur', 'payments/'.$relativepath, 0).' | ';
- print ''.dol_print_size(dol_filesize($tfile)).' | ';
- print ''.dol_print_date(dol_filemtime($tfile), "dayhour").' | ';
- }
- }
- closedir($handle);
- }
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle)) !== false)
+ {
+ if (preg_match('/^supplier_payment/i', $file))
+ {
+ $tfile = $dir.'/'.$year.'/'.$file;
+ $relativepath = $year.'/'.$file;
+ print '| '.img_pdf().' '.$file.''.$formfile->showPreview($file, 'facture_fournisseur', 'payments/'.$relativepath, 0).' | ';
+ print ''.dol_print_size(dol_filesize($tfile)).' | ';
+ print ''.dol_print_date(dol_filemtime($tfile), "dayhour").' | ';
+ }
+ }
+ closedir($handle);
+ }
- print ' ';
- }
+ print ' ';
+ }
}
// End of page
diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
index 0826a4ab200..4456d27c539 100644
--- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php
@@ -40,29 +40,29 @@ $langs->load("bills");
$total = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink)
{
- $ilink++;
+ $ilink++;
- $trclass = 'oddeven';
- if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
- ?>
+ $trclass = 'oddeven';
+ if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
+ ?>
|
| trans("SupplierInvoice"); ?> |
trans("ShowBill"), "bill").' '.$objectlink->ref; ?> |
ref_supplier; ?> |
date, 'day'); ?> |
rights->fournisseur->facture->lire) {
- $sign = 1;
- if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1;
- if ($objectlink->statut != 3)
- {
+ if ($user->rights->fournisseur->facture->lire) {
+ $sign = 1;
+ if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1;
+ if ($objectlink->statut != 3)
+ {
// If not abandonned
- $total = $total + $sign * $objectlink->total_ht;
- echo price($objectlink->total_ht);
- } else {
- echo ''.price($objectlink->total_ht).'';
- }
- } ?> |
+ $total = $total + $sign * $objectlink->total_ht;
+ echo price($objectlink->total_ht);
+ } else {
+ echo ''.price($objectlink->total_ht).'';
+ }
+ } ?>
getLibStatut(3); ?> |
id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> |
@@ -70,7 +70,7 @@ foreach ($linkedObjectBlock as $key => $objectlink)
}
if (count($linkedObjectBlock) > 1)
{
- ?>
+ ?>
| trans("Total"); ?> |
|
diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php
index 566f3a1105a..80f6d2eed5e 100644
--- a/htdocs/fourn/paiement/card.php
+++ b/htdocs/fourn/paiement/card.php
@@ -292,7 +292,7 @@ if ($result > 0)
$facturestatic->total_tva = $objp->total_tva;
$facturestatic->total_ttc = $objp->total_ttc;
$facturestatic->statut = $objp->status;
- $facturestatic->alreadypaid = -1; // unknown
+ $facturestatic->alreadypaid = -1; // unknown
print ' ';
// Ref
diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php
index bbb469e4ffd..3fca286eff0 100644
--- a/htdocs/fourn/paiement/list.php
+++ b/htdocs/fourn/paiement/list.php
@@ -56,29 +56,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'bills', 'banks', 'compta'));
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
$massaction = GETPOST('massaction', 'alpha');
-$optioncss = GETPOST('optioncss', 'alpha');
+$optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist';
-$socid = GETPOST('socid', 'int');
+$socid = GETPOST('socid', 'int');
$search_ref = GETPOST('search_ref', 'alpha');
$search_day = GETPOST('search_day', 'int');
-$search_month = GETPOST('search_month', 'int');
+$search_month = GETPOST('search_month', 'int');
$search_year = GETPOST('search_year', 'int');
-$search_company = GETPOST('search_company', 'alpha');
+$search_company = GETPOST('search_company', 'alpha');
$search_payment_type = GETPOST('search_payment_type');
-$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
+$search_cheque_num = GETPOST('search_cheque_num', 'alpha');
$search_bank_account = GETPOST('search_bank_account', 'int');
-$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
+$search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be able to search on '< x'
-$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
-if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php
index e3d2b5b91d2..04310945cf7 100644
--- a/htdocs/fourn/product/list.php
+++ b/htdocs/fourn/product/list.php
@@ -81,22 +81,22 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
- {
- $sref = '';
- $sRefSupplier = '';
- $snom = '';
- $search_field1 = '';
- $search_field2 = '';
- $search_date_creation = '';
- $search_date_update = '';
- $toselect = '';
- $search_array_options = array();
- }
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
+ {
+ $sref = '';
+ $sRefSupplier = '';
+ $snom = '';
+ $search_field1 = '';
+ $search_field2 = '';
+ $search_date_creation = '';
+ $search_date_update = '';
+ $toselect = '';
+ $search_array_options = array();
+ }
}
/*
@@ -119,8 +119,8 @@ if ($fourn_id)
$arrayofmassactions = array(
'generate_doc'=>$langs->trans("ReGeneratePDF"),
- 'builddoc'=>$langs->trans("PDFMerge"),
- 'presend'=>$langs->trans("SendByMail"),
+ 'builddoc'=>$langs->trans("PDFMerge"),
+ 'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
@@ -177,13 +177,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
- if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
- {
- $page = 0;
- $offset = 0;
- }
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+ if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
+ {
+ $page = 0;
+ $offset = 0;
+ }
}
$sql .= $db->plimit($limit + 1, $offset);
@@ -224,12 +224,12 @@ if ($resql)
}
print ' \n";
@@ -318,10 +318,10 @@ if ($resql)
print ''.(isset($objp->unitprice) ? price($objp->unitprice) : '').' | ';
// add additional columns from hooks
- $parameters = array();
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action);
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- print $hookmanager->resPrint;
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action);
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ print $hookmanager->resPrint;
print ' | ';
diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php
index bf5ba036966..736a7bf4f90 100644
--- a/htdocs/fourn/recap-fourn.php
+++ b/htdocs/fourn/recap-fourn.php
@@ -34,8 +34,8 @@ $langs->loadLangs(array('bills', 'companies'));
$socid = GETPOST("socid", 'int');
if ($user->socid > 0)
{
- $action = '';
- $socid = $user->socid;
+ $action = '';
+ $socid = $user->socid;
}
@@ -53,138 +53,138 @@ llxHeader();
if ($socid > 0)
{
- $societe = new Societe($db);
- $societe->fetch($socid);
+ $societe = new Societe($db);
+ $societe->fetch($socid);
- /*
+ /*
* Affichage onglets
*/
- $head = societe_prepare_head($societe);
+ $head = societe_prepare_head($societe);
- print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company');
+ print dol_get_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($societe, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
print dol_get_fiche_end();
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->facture->lire)
- {
- // Invoice list
- print load_fiche_titre($langs->trans("SupplierPreview"));
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->facture->lire)
+ {
+ // Invoice list
+ print load_fiche_titre($langs->trans("SupplierPreview"));
- print '';
+ print '';
- $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,";
- $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
- $sql .= " u.login, u.rowid as userid";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
- $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
- $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany
- $sql .= " AND f.fk_user_valid = u.rowid";
- $sql .= " ORDER BY f.datef DESC";
+ $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,";
+ $sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
+ $sql .= " u.login, u.rowid as userid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
+ $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id;
+ $sql .= " AND f.entity IN (".getEntity("facture_fourn").")"; // Recognition of the entity attributed to this invoice for Multicompany
+ $sql .= " AND f.fk_user_valid = u.rowid";
+ $sql .= " ORDER BY f.datef DESC";
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
- print '';
- print '| '.$langs->trans("Date").' | ';
- print ' | ';
- print ''.$langs->trans("Status").' | ';
- print ''.$langs->trans("Debit").' | ';
- print ''.$langs->trans("Credit").' | ';
- print ''.$langs->trans("Balance").' | ';
- print ' | ';
- print ' ';
+ print '';
+ print '| '.$langs->trans("Date").' | ';
+ print ' | ';
+ print ''.$langs->trans("Status").' | ';
+ print ''.$langs->trans("Debit").' | ';
+ print ''.$langs->trans("Credit").' | ';
+ print ''.$langs->trans("Balance").' | ';
+ print ' | ';
+ print ' ';
- if (!$num > 0)
- {
- print '| '.$langs->trans("NoInvoice").' | ';
- }
+ if (!$num > 0)
+ {
+ print '| '.$langs->trans("NoInvoice").' | ';
+ }
- $solde = 0;
+ $solde = 0;
- // Boucle sur chaque facture
- for ($i = 0; $i < $num; $i++)
- {
- $objf = $db->fetch_object($resql);
+ // Boucle sur chaque facture
+ for ($i = 0; $i < $num; $i++)
+ {
+ $objf = $db->fetch_object($resql);
- $fac = new FactureFournisseur($db);
- $ret = $fac->fetch($objf->facid);
- if ($ret < 0)
- {
- print $fac->error." ";
- continue;
- }
- $totalpaye = $fac->getSommePaiement();
+ $fac = new FactureFournisseur($db);
+ $ret = $fac->fetch($objf->facid);
+ if ($ret < 0)
+ {
+ print $fac->error." ";
+ continue;
+ }
+ $totalpaye = $fac->getSommePaiement();
- print '';
+ print ' ';
- print "| ".dol_print_date($fac->date)." | \n";
- print "id\">".img_object($langs->trans("ShowBill"), "bill")." ".$fac->ref." | \n";
+ print "".dol_print_date($fac->date)." | \n";
+ print "id\">".img_object($langs->trans("ShowBill"), "bill")." ".$fac->ref." | \n";
- print ''.$fac->getLibStatut(2, $totalpaye).' | ';
- print ''.price($fac->total_ttc)." | \n";
- $solde = $solde + $fac->total_ttc;
+ print ''.$fac->getLibStatut(2, $totalpaye).' | ';
+ print ''.price($fac->total_ttc)." | \n";
+ $solde = $solde + $fac->total_ttc;
- print ' | ';
- print ''.price($solde)." | \n";
+ print ' | ';
+ print ''.price($solde)." | \n";
- // Author
- print ''.img_object($langs->trans("ShowUser"), 'user').' '.$objf->login.' | ';
+ // Author
+ print ''.img_object($langs->trans("ShowUser"), 'user').' '.$objf->login.' | ';
- print " \n";
+ print "\n";
- // Payments
- $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
- $sql .= " p.fk_user_author, u.login, u.rowid as userid";
- $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
- $sql .= " ".MAIN_DB_PREFIX."paiementfourn as p";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
- $sql .= " WHERE pf.fk_paiementfourn = p.rowid";
- $sql .= " AND pf.fk_facturefourn = ".$fac->id;
+ // Payments
+ $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
+ $sql .= " p.fk_user_author, u.login, u.rowid as userid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
+ $sql .= " ".MAIN_DB_PREFIX."paiementfourn as p";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_author = u.rowid";
+ $sql .= " WHERE pf.fk_paiementfourn = p.rowid";
+ $sql .= " AND pf.fk_facturefourn = ".$fac->id;
- $resqlp = $db->query($sql);
- if ($resqlp)
- {
- $nump = $db->num_rows($resqlp);
- $j = 0;
+ $resqlp = $db->query($sql);
+ if ($resqlp)
+ {
+ $nump = $db->num_rows($resqlp);
+ $j = 0;
- while ($j < $nump)
- {
- $objp = $db->fetch_object($resqlp);
- //
- print '';
- print '| '.dol_print_date($db->jdate($objp->dp))." | \n";
- print '';
- print ' '; // Decalage
- print ''.img_object($langs->trans("ShowPayment"), "payment").' '.$langs->trans("Payment").' '.$objp->rowid.' | ';
- print " | \n";
- print " | \n";
- print ''.price($objp->amount).' | ';
- $solde = $solde - $objp->amount;
- print ''.price($solde)." | \n";
+ while ($j < $nump)
+ {
+ $objp = $db->fetch_object($resqlp);
+ //
+ print ' ';
+ print '| '.dol_print_date($db->jdate($objp->dp))." | \n";
+ print '';
+ print ' '; // Decalage
+ print ''.img_object($langs->trans("ShowPayment"), "payment").' '.$langs->trans("Payment").' '.$objp->rowid.' | ';
+ print " | \n";
+ print " | \n";
+ print ''.price($objp->amount).' | ';
+ $solde = $solde - $objp->amount;
+ print ''.price($solde)." | \n";
- // Auteur
- print ''.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.' | ';
+ // Auteur
+ print ''.img_object($langs->trans("ShowUser"), 'user').' '.$objp->login.' | ';
- print ' ';
+ print '';
- $j++;
- }
+ $j++;
+ }
- $db->free($resqlp);
- } else {
- dol_print_error($db);
- }
- }
- } else {
- dol_print_error($db);
- }
+ $db->free($resqlp);
+ } else {
+ dol_print_error($db);
+ }
+ }
+ } else {
+ dol_print_error($db);
+ }
- print " ";
- }
+ print " ";
+ }
} else {
- dol_print_error($db);
+ dol_print_error($db);
}
// End of page
diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php
index 70a96546fc2..6a51d6d0a88 100644
--- a/htdocs/ftp/admin/ftpclient.php
+++ b/htdocs/ftp/admin/ftpclient.php
@@ -114,16 +114,16 @@ if (GETPOST('delete', 'alpha'))
if ($result4) $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity);
if ($result4) $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity);
- if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
- {
- $db->commit();
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- } else {
- $db->rollback();
- dol_print_error($db);
- }
- }
+ if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
+ {
+ $db->commit();
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ } else {
+ $db->rollback();
+ dol_print_error($db);
+ }
+ }
}
diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php
index 7c0eab0f352..51a8028e1f3 100644
--- a/htdocs/ftp/index.php
+++ b/htdocs/ftp/index.php
@@ -108,7 +108,7 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
{
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
} elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
- // Files infected by a virus
+ // Files infected by a virus
setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
} else // Known error
{
@@ -158,10 +158,10 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
- $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
+ $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
- $langs->load("other");
+ $langs->load("other");
// Remote file
$filename = $file;
@@ -210,14 +210,14 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
{
if ($const["check"]) // Is checkbox checked
{
- $langs->load("other");
+ $langs->load("other");
// Remote file
$file = $const["file"];
$newsection = $const["section"];
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
- $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
+ $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = utf8_decode($remotefile);
@@ -265,7 +265,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
- $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
+ $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
@@ -314,7 +314,7 @@ if ($action == 'download')
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
- $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
+ $newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
@@ -323,7 +323,7 @@ if ($action == 'download')
$newremotefileiso = utf8_decode($remotefile);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
- $result = fopen('ssh2.sftp://' . intval($conn_id) . $newremotefileiso, 'r');
+ $result = fopen('ssh2.sftp://'.intval($conn_id).$newremotefileiso, 'r');
} else {
$result = ftp_get($conn_id, $localfile, $newremotefileiso, FTP_BINARY);
}
@@ -415,7 +415,7 @@ if (!function_exists('ftp_connect'))
{
print $langs->trans("FTPFeatureNotSupportedByYourPHP");
} else {
- if (!empty($ftp_server))
+ if (!empty($ftp_server))
{
// Confirm remove file
if ($action == 'delete')
@@ -432,9 +432,9 @@ if (!function_exists('ftp_connect'))
print $langs->trans("Server").': '.$ftp_server.' ';
print $langs->trans("Port").': '.$ftp_port.' '.($ftp_passive ? "(Passive)" : "(Active)").' ';
print $langs->trans("User").': '.$ftp_user.' ';
- print $langs->trans("FTPs (FTP over SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SSL).' ';
- print $langs->trans("SFTP (FTP as a subsytem of SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SFTP).' ';
- print $langs->trans("Directory").': ';
+ print $langs->trans("FTPs (FTP over SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SSL).' ';
+ print $langs->trans("SFTP (FTP as a subsytem of SSH)").': '.yn($conf->global->FTP_CONNECT_WITH_SFTP).' ';
+ print $langs->trans("Directory").': ';
$sectionarray = preg_split('|[\/]|', $section);
// For /
$newsection = '/';
@@ -461,7 +461,7 @@ if (!function_exists('ftp_connect'))
print " \n";
print '';
diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php
index 3f89dc531ff..192c7d24e33 100644
--- a/htdocs/holiday/document.php
+++ b/htdocs/holiday/document.php
@@ -119,114 +119,114 @@ if ($object->id)
print '';
- print '';
- print '| '.$langs->trans("User").' | ';
+ print ' ';
+ print '| '.$langs->trans("User").' | ';
print '';
print $userRequest->getNomUrl(-1, 'leave');
print ' | ';
- // Type
- print '';
- print '| '.$langs->trans("Type").' | ';
- print '';
- $typeleaves = $object->getTypes(1, -1);
- $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']);
- print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
- print ' | ';
- print ' ';
+ // Type
+ print '';
+ print '| '.$langs->trans("Type").' | ';
+ print '';
+ $typeleaves = $object->getTypes(1, -1);
+ $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code']) != $typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']);
+ print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $object->fk_type) : $labeltoshow;
+ print ' | ';
+ print ' ';
- $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
- $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
+ $starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
+ $endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
- if (!$edit)
- {
- print '';
- print '| ';
- print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
- print ' | ';
- print ''.dol_print_date($object->date_debut, 'day');
- print ' ';
- print ''.$langs->trans($listhalfday[$starthalfday]).'';
- print ' | ';
- print ' ';
- } else {
- print '';
- print '| ';
- print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
- print ' | ';
- print '';
- print $form->selectDate($object->date_debut, 'date_debut_');
- print ' ';
+ if (!$edit)
+ {
+ print ' | ';
+ print '| ';
+ print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
+ print ' | ';
+ print ''.dol_print_date($object->date_debut, 'day');
+ print ' ';
+ print ''.$langs->trans($listhalfday[$starthalfday]).'';
+ print ' | ';
+ print ' ';
+ } else {
+ print '';
+ print '| ';
+ print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
+ print ' | ';
+ print '';
+ print $form->selectDate($object->date_debut, 'date_debut_');
+ print ' ';
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday') ?GETPOST('starthalfday') : $starthalfday));
- print ' | ';
- print ' ';
- }
+ print '';
+ print '';
+ }
- if (!$edit)
- {
- print '';
- print '| ';
- print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
- print ' | ';
- print ''.dol_print_date($object->date_fin, 'day');
- print ' ';
- print ''.$langs->trans($listhalfday[$endhalfday]).'';
- print ' | ';
- print ' ';
- } else {
- print '';
- print '| ';
- print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
- print ' | ';
- print '';
- print $form->selectDate($object->date_fin, 'date_fin_');
- print ' ';
- print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday') ?GETPOST('endhalfday') : $endhalfday));
- print ' | ';
- print ' ';
- }
+ if (!$edit)
+ {
+ print '';
+ print '| ';
+ print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
+ print ' | ';
+ print ''.dol_print_date($object->date_fin, 'day');
+ print ' ';
+ print ''.$langs->trans($listhalfday[$endhalfday]).'';
+ print ' | ';
+ print ' ';
+ } else {
+ print '';
+ print '| ';
+ print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
+ print ' | ';
+ print '';
+ print $form->selectDate($object->date_fin, 'date_fin_');
+ print ' ';
+ print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday') ?GETPOST('endhalfday') : $endhalfday));
+ print ' | ';
+ print ' ';
+ }
- // Nb days consumed
- print '';
- print '';
- $htmlhelp = $langs->trans('NbUseDaysCPHelp');
- $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
- $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
- if ($includesaturday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
- if ($includesunday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
- print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
- print ' | ';
- print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).' | ';
- print ' ';
+ // Nb days consumed
+ print '';
+ print '';
+ $htmlhelp = $langs->trans('NbUseDaysCPHelp');
+ $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
+ $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
+ if ($includesaturday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
+ if ($includesunday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
+ print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
+ print ' | ';
+ print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).' | ';
+ print ' ';
- if ($object->statut == 5)
- {
- print '';
- print '| '.$langs->trans('DetailRefusCP').' | ';
- print ''.$object->detail_refuse.' | ';
- print ' ';
- }
+ if ($object->statut == 5)
+ {
+ print '';
+ print '| '.$langs->trans('DetailRefusCP').' | ';
+ print ''.$object->detail_refuse.' | ';
+ print ' ';
+ }
- // Description
- if (!$edit)
- {
- print '';
- print '| '.$langs->trans('DescCP').' | ';
- print ''.nl2br($object->description).' | ';
- print ' ';
- } else {
- print '';
- print '| '.$langs->trans('DescCP').' | ';
- print ' | ';
- print ' ';
- }
+ // Description
+ if (!$edit)
+ {
+ print '';
+ print '| '.$langs->trans('DescCP').' | ';
+ print ''.nl2br($object->description).' | ';
+ print ' ';
+ } else {
+ print '';
+ print '| '.$langs->trans('DescCP').' | ';
+ print ' | ';
+ print ' ';
+ }
- print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' | ';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize, 1, 1).' | ';
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' | ';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.dol_print_size($totalsize, 1, 1).' | ';
- print '';
- print ' '."\n";
- /*
+ print '';
+ print ' '."\n";
+ /*
print ' ';
print ' ';
print ' ';
@@ -288,19 +288,19 @@ if ($object->id)
print ' ';
print ' '; */
- print ' ';
+ print '';
- print '';
+ print '';
- print dol_get_fiche_end();
+ print dol_get_fiche_end();
- $modulepart = 'holiday';
- $permission = $user->rights->holiday->write;
- $permtoedit = $user->rights->holiday->write;
- $param = '&id='.$object->id;
- include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
+ $modulepart = 'holiday';
+ $permission = $user->rights->holiday->write;
+ $permtoedit = $user->rights->holiday->write;
+ $param = '&id='.$object->id;
+ include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
} else {
print $langs->trans("ErrorUnknown");
}
diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php
index c2fd48e573a..f16375209e1 100644
--- a/htdocs/holiday/list.php
+++ b/htdocs/holiday/list.php
@@ -68,14 +68,14 @@ $result = restrictedArea($user, 'holiday', '', '');
// If we are on the view of a specific user
if ($id > 0)
{
- $canread = 0;
- if ($id == $user->id) $canread = 1;
- if (!empty($user->rights->holiday->read_all)) $canread = 1;
- if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1;
- if (!$canread)
- {
- accessforbidden();
- }
+ $canread = 0;
+ if ($id == $user->id) $canread = 1;
+ if (!empty($user->rights->holiday->read_all)) $canread = 1;
+ if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1;
+ if (!$canread)
+ {
+ accessforbidden();
+ }
}
$diroutputmassaction = $conf->holiday->dir_output.'/temp/massgeneration/'.$user->id;
@@ -122,9 +122,9 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'cp.ref'=>'Ref',
- 'cp.description'=>'Description',
- 'uu.lastname'=>'EmployeeLastname',
- 'uu.firstname'=>'EmployeeFirstname',
+ 'cp.description'=>'Description',
+ 'uu.lastname'=>'EmployeeLastname',
+ 'uu.firstname'=>'EmployeeFirstname',
'uu.login'=>'Login'
);
@@ -176,7 +176,7 @@ if (empty($reshook))
$search_ref = "";
$search_month_create = "";
$search_year_create = "";
- $search_month_start = "";
+ $search_month_start = "";
$search_year_start = "";
$search_month_end = "";
$search_year_end = "";
@@ -404,15 +404,15 @@ if ($resql)
print dol_get_fiche_head($head, 'paidholidays', $title, -1, 'user');
- dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
+ dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
- print '';
+ print '';
- print ' ';
+ print ' ';
- showMyBalance($object, $user_id);
+ showMyBalance($object, $user_id);
}
print dol_get_fiche_end();
@@ -445,8 +445,8 @@ if ($resql)
if ($sall)
{
- foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
- print ''.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).' ';
+ foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
+ print ''.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).' ';
}
$moreforfilter = '';
@@ -509,16 +509,16 @@ if ($resql)
{
if ($user->rights->holiday->read_all)
{
- print '';
- $validator = new UserGroup($db);
- $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id;
- $valideurobjects = $validator->listUsersForGroup($excludefilter);
- $valideurarray = array();
- foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id;
- print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150');
- print ' | ';
+ print '';
+ $validator = new UserGroup($db);
+ $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id;
+ $valideurobjects = $validator->listUsersForGroup($excludefilter);
+ $valideurarray = array();
+ foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id;
+ print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150');
+ print ' | ';
} else {
- print ' | ';
+ print ' | ';
}
}
@@ -637,9 +637,9 @@ if ($resql)
$result = 0;
} elseif ($num > 0 && !empty($mysoc->country_id))
{
- // Lines
- $userstatic = new User($db);
- $approbatorstatic = new User($db);
+ // Lines
+ $userstatic = new User($db);
+ $approbatorstatic = new User($db);
$typeleaves = $object->getTypes(1, -1);
@@ -756,14 +756,14 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
- // Action column
- print '';
+ // Action column
+ print ' | ';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- {
- $selected = 0;
+ {
+ $selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
print '';
- }
+ }
print ' | ';
if (!$i) $totalarray['nbfield']++;
diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php
index 7e7e7ed29f9..5108c97f54a 100644
--- a/htdocs/holiday/month_report.php
+++ b/htdocs/holiday/month_report.php
@@ -57,8 +57,8 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha');
-if (! $sortfield) $sortfield = "cp.rowid";
-if (! $sortorder) $sortorder = "ASC";
+if (!$sortfield) $sortfield = "cp.rowid";
+if (!$sortorder) $sortorder = "ASC";
$hookmanager->initHooks(array('leavemovementlist'));
@@ -78,42 +78,42 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
- {
- $search_ref = '';
- $search_employee = '';
- $search_type = '';
- $search_description = '';
- $toselect = '';
- $search_array_options = array();
- }
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
+ {
+ $search_ref = '';
+ $search_employee = '';
+ $search_type = '';
+ $search_description = '';
+ $toselect = '';
+ $search_array_options = array();
+ }
- if (GETPOST('button_removefilter_x', 'alpha')
- || GETPOST('button_removefilter.x', 'alpha')
- || GETPOST('button_removefilter', 'alpha')
- || GETPOST('button_search_x', 'alpha')
- || GETPOST('button_search.x', 'alpha')
- || GETPOST('button_search', 'alpha'))
- {
- $massaction = '';
- }
+ if (GETPOST('button_removefilter_x', 'alpha')
+ || GETPOST('button_removefilter.x', 'alpha')
+ || GETPOST('button_removefilter', 'alpha')
+ || GETPOST('button_search_x', 'alpha')
+ || GETPOST('button_search.x', 'alpha')
+ || GETPOST('button_search', 'alpha'))
+ {
+ $massaction = '';
+ }
}
$arrayfields = array(
- 'cp.ref'=>array('label'=>$langs->trans('Ref'), 'checked'=>1),
- 'cp.fk_user'=>array('label'=>$langs->trans('Employee'), 'checked'=>1),
- 'ct.label'=>array('label'=>$langs->trans('Type'), 'checked'=>1),
- 'cp.date_debut'=>array('label'=>$langs->trans('DateDebCP'), 'checked'=>1),
- 'cp.date_fin'=>array('label'=>$langs->trans('DateFinCP'), 'checked'=>1),
- 'used_days'=>array('label'=>$langs->trans('NbUseDaysCPShort'), 'checked'=>1),
- 'date_start_month'=>array('label'=>$langs->trans('DateStartInMonth'), 'checked'=>1),
- 'date_end_month'=>array('label'=>$langs->trans('DateEndInMonth'), 'checked'=>1),
- 'used_days_month'=>array('label'=>$langs->trans('NbUseDaysCPShortInMonth'), 'checked'=>1),
- 'cp.description'=>array('label'=>$langs->trans('DescCP'), 'checked'=>1),
+ 'cp.ref'=>array('label'=>$langs->trans('Ref'), 'checked'=>1),
+ 'cp.fk_user'=>array('label'=>$langs->trans('Employee'), 'checked'=>1),
+ 'ct.label'=>array('label'=>$langs->trans('Type'), 'checked'=>1),
+ 'cp.date_debut'=>array('label'=>$langs->trans('DateDebCP'), 'checked'=>1),
+ 'cp.date_fin'=>array('label'=>$langs->trans('DateFinCP'), 'checked'=>1),
+ 'used_days'=>array('label'=>$langs->trans('NbUseDaysCPShort'), 'checked'=>1),
+ 'date_start_month'=>array('label'=>$langs->trans('DateStartInMonth'), 'checked'=>1),
+ 'date_end_month'=>array('label'=>$langs->trans('DateEndInMonth'), 'checked'=>1),
+ 'used_days_month'=>array('label'=>$langs->trans('NbUseDaysCPShortInMonth'), 'checked'=>1),
+ 'cp.description'=>array('label'=>$langs->trans('DescCP'), 'checked'=>1),
);
@@ -134,19 +134,19 @@ $search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", ti
$year_month = sprintf("%04d", $search_year).'-'.sprintf("%02d", $search_month);
$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday";
-$sql.= " FROM ".MAIN_DB_PREFIX."holiday cp";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid";
-$sql.= " WHERE cp.rowid > 0";
-$sql.= " AND cp.statut = 3"; // 3 = Approved
-$sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
+$sql .= " FROM ".MAIN_DB_PREFIX."holiday cp";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid";
+$sql .= " WHERE cp.rowid > 0";
+$sql .= " AND cp.statut = 3"; // 3 = Approved
+$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref);
if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
-if (!empty($search_description)) $sql.= natural_search('cp.description', $search_description);
+if (!empty($search_description)) $sql .= natural_search('cp.description', $search_description);
-$sql.= $db->order($sortfield, $sortorder);
+$sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql);
if (empty($resql))
@@ -158,7 +158,7 @@ if (empty($resql))
$num = $db->num_rows($resql);
$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage);
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref);
if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee);
@@ -190,7 +190,7 @@ $moreforfilter = '';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = '';
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
-$selectedfields.= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
+$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '';
print ' ';
@@ -199,31 +199,31 @@ print '';
// Filter: Ref
if (!empty($arrayfields['cp.ref']['checked'])) {
- print '| ';
- print '';
- print ' | ';
+ print '';
+ print '';
+ print ' | ';
}
// Filter: Employee
if (!empty($arrayfields['cp.fk_user']['checked'])) {
- print '';
- print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
- print ' | ';
+ print '';
+ print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
+ print ' | ';
}
// Filter: Type
if (!empty($arrayfields['ct.label']['checked'])) {
- $typeleaves = $holidaystatic->getTypes(1, -1);
- $arraytypeleaves = array();
- foreach ($typeleaves as $key => $val)
- {
- $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
- $arraytypeleaves[$val['rowid']] = $labeltoshow;
- }
+ $typeleaves = $holidaystatic->getTypes(1, -1);
+ $arraytypeleaves = array();
+ foreach ($typeleaves as $key => $val)
+ {
+ $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
+ $arraytypeleaves[$val['rowid']] = $labeltoshow;
+ }
- print '';
- print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1);
- print ' | ';
+ print '';
+ print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1);
+ print ' | ';
}
if (!empty($arrayfields['cp.date_debut']['checked'])) print ' | ';
@@ -235,9 +235,9 @@ if (!empty($arrayfields['used_days_month']['checked'])) print '';
- print '';
- print ' | ';
+ print '';
+ print '';
+ print ' | ';
}
// Action column
@@ -263,93 +263,93 @@ print ' ';
if ($num == 0)
{
- print '| '.$langs->trans('None').' | ';
+ print '| '.$langs->trans('None').' | ';
}
else {
- while ($obj = $db->fetch_object($resql))
- {
- $user = new User($db);
- $user->fetch($obj->fk_user);
+ while ($obj = $db->fetch_object($resql))
+ {
+ $user = new User($db);
+ $user->fetch($obj->fk_user);
- $date_start = $db->jdate($obj->date_debut, true);
- $date_end = $db->jdate($obj->date_fin, true);
+ $date_start = $db->jdate($obj->date_debut, true);
+ $date_end = $db->jdate($obj->date_fin, true);
- $tmpstart = dol_getdate($date_start);
- $tmpend = dol_getdate($date_end);
+ $tmpstart = dol_getdate($date_start);
+ $tmpend = dol_getdate($date_end);
- $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
- $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
+ $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning';
+ $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon';
- $halfdayinmonth = $obj->halfday;
- $starthalfdayinmonth = $starthalfday;
- $endhalfdayinmonth = $endhalfday;
+ $halfdayinmonth = $obj->halfday;
+ $starthalfdayinmonth = $starthalfday;
+ $endhalfdayinmonth = $endhalfday;
- //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning
+ //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning
- // Set date_start_gmt and date_end_gmt that are date to show for the selected month
- $date_start_inmonth = $db->jdate($obj->date_debut, true);
- $date_end_inmonth = $db->jdate($obj->date_fin, true);
- if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month)
- {
- $date_start_inmonth = dol_get_first_day($search_year, $search_month, true);
- $starthalfdayinmonth = 'morning';
- if ($halfdayinmonth == 2) $halfdayinmonth = 1;
- if ($halfdayinmonth == -1) $halfdayinmonth = 0;
- }
- if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month)
- {
- $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1);
- $endhalfdayinmonth = 'afternoon';
- if ($halfdayinmonth == 2) $halfdayinmonth = -1;
- if ($halfdayinmonth == 1) $halfdayinmonth = 0;
- }
+ // Set date_start_gmt and date_end_gmt that are date to show for the selected month
+ $date_start_inmonth = $db->jdate($obj->date_debut, true);
+ $date_end_inmonth = $db->jdate($obj->date_fin, true);
+ if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month)
+ {
+ $date_start_inmonth = dol_get_first_day($search_year, $search_month, true);
+ $starthalfdayinmonth = 'morning';
+ if ($halfdayinmonth == 2) $halfdayinmonth = 1;
+ if ($halfdayinmonth == -1) $halfdayinmonth = 0;
+ }
+ if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month)
+ {
+ $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1);
+ $endhalfdayinmonth = 'afternoon';
+ if ($halfdayinmonth == 2) $halfdayinmonth = -1;
+ if ($halfdayinmonth == 1) $halfdayinmonth = 0;
+ }
- // Leave request
- $holidaystatic->id = $obj->rowid;
- $holidaystatic->ref = $obj->ref;
+ // Leave request
+ $holidaystatic->id = $obj->rowid;
+ $holidaystatic->ref = $obj->ref;
- print '';
+ print ' ';
- if (!empty($arrayfields['cp.ref']['checked'])) print '| '.$holidaystatic->getNomUrl(1, 1).' | ';
- if (!empty($arrayfields['cp.fk_user']['checked'])) print ''.$user->getFullName($langs).' | ';
- if (!empty($arrayfields['ct.label']['checked'])) print ''.$obj->label.' | ';
+ if (!empty($arrayfields['cp.ref']['checked'])) print ''.$holidaystatic->getNomUrl(1, 1).' | ';
+ if (!empty($arrayfields['cp.fk_user']['checked'])) print ''.$user->getFullName($langs).' | ';
+ if (!empty($arrayfields['ct.label']['checked'])) print ''.$obj->label.' | ';
- if (!empty($arrayfields['cp.date_debut']['checked']))
- {
- print ''.dol_print_date($db->jdate($obj->date_debut), 'day');
- print ' ('.$langs->trans($listhalfday[$starthalfday]).')';
- print ' | ';
- }
+ if (!empty($arrayfields['cp.date_debut']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($obj->date_debut), 'day');
+ print ' ('.$langs->trans($listhalfday[$starthalfday]).')';
+ print ' | ';
+ }
- if (!empty($arrayfields['cp.date_fin']['checked']))
- {
- print ''.dol_print_date($db->jdate($obj->date_fin), 'day');
- print ' ('.$langs->trans($listhalfday[$endhalfday]).')';
- print ' | ';
- }
+ if (!empty($arrayfields['cp.date_fin']['checked']))
+ {
+ print ''.dol_print_date($db->jdate($obj->date_fin), 'day');
+ print ' ('.$langs->trans($listhalfday[$endhalfday]).')';
+ print ' | ';
+ }
- if (!empty($arrayfields['used_days']['checked'])) print ''.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).' | ';
+ if (!empty($arrayfields['used_days']['checked'])) print ''.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).' | ';
- if (!empty($arrayfields['date_start_month']['checked']))
- {
- print ''.dol_print_date($date_start_inmonth, 'day');
- print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')';
- print ' | ';
- }
+ if (!empty($arrayfields['date_start_month']['checked']))
+ {
+ print ''.dol_print_date($date_start_inmonth, 'day');
+ print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')';
+ print ' | ';
+ }
- if (!empty($arrayfields['date_end_month']['checked']))
- {
- print ''.dol_print_date($date_end_inmonth, 'day');
- print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')';
- print ' | ';
- }
+ if (!empty($arrayfields['date_end_month']['checked']))
+ {
+ print ''.dol_print_date($date_end_inmonth, 'day');
+ print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')';
+ print ' | ';
+ }
- if (!empty($arrayfields['used_days_month']['checked'])) print ''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).' | ';
- if (!empty($arrayfields['cp.description']['checked'])) print ''.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).' | ';
+ if (!empty($arrayfields['used_days_month']['checked'])) print ''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).' | ';
+ if (!empty($arrayfields['cp.description']['checked'])) print ''.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).' | ';
- print ' | ';
- print ' ';
- }
+ print ' | ';
+ print '';
+ }
}
print ' ';
print ' ';
diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php
index 7043f436e87..669bb9aa32f 100644
--- a/htdocs/holiday/view_log.php
+++ b/htdocs/holiday/view_log.php
@@ -36,15 +36,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
-$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
-$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
-$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
-$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
-$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
-$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
-$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
-$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
+$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
+$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
+$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
+$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
+$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
+$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search
+$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
+$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$search_id = GETPOST('search_id', 'alphanohtml');
$search_month = GETPOST('search_month', 'int');
@@ -65,8 +65,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST(
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (! $sortfield) $sortfield="cpl.rowid";
-if (! $sortorder) $sortorder="DESC";
+if (!$sortfield) $sortfield = "cpl.rowid";
+if (!$sortorder) $sortorder = "DESC";
// Si l'utilisateur n'a pas le droit de lire cette page
if (!$user->rights->holiday->read_all) accessforbidden();
@@ -174,13 +174,13 @@ if (!empty($search_year) && $search_year > 0) {
$sqlwhere .= "AND date_action BETWEEN '".$db->idate($from_date)."' AND '".$db->idate($to_date)."'";
}
-if (!empty($search_id) && $search_id > 0) $sqlwhere.= natural_search('rowid', $search_id, 1);
-if (!empty($search_validator) && $search_validator > 0) $sqlwhere.= natural_search('fk_user_action', $search_validator, 1);
-if (!empty($search_employee) && $search_employee > 0) $sqlwhere.= natural_search('fk_user_update', $search_employee, 1);
-if (!empty($search_description)) $sqlwhere.= natural_search('type_action', $search_description);
-if (!empty($search_type) && $search_type > 0) $sqlwhere.= natural_search('fk_type', $search_type, 1);
-if (!empty($search_prev_solde)) $sqlwhere.= natural_search('prev_solde', $search_prev_solde, 1);
-if (!empty($search_new_solde)) $sqlwhere.= natural_search('new_solde', $search_new_solde, 1);
+if (!empty($search_id) && $search_id > 0) $sqlwhere .= natural_search('rowid', $search_id, 1);
+if (!empty($search_validator) && $search_validator > 0) $sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
+if (!empty($search_employee) && $search_employee > 0) $sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
+if (!empty($search_description)) $sqlwhere .= natural_search('type_action', $search_description);
+if (!empty($search_type) && $search_type > 0) $sqlwhere .= natural_search('fk_type', $search_type, 1);
+if (!empty($search_prev_solde)) $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
+if (!empty($search_new_solde)) $sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
$sqlorder = $db->order($sortfield, $sortorder);
@@ -248,8 +248,8 @@ $moreforfilter = '';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = '';
-$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
-$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
+$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
+$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '';
print ' ';
@@ -358,13 +358,13 @@ while ($i < min($num, $limit))
//TODO: $obj = $db->fetch_object($resql);
$obj = next($object->logs);
- $holidaylogstatic->id = $obj['rowid'];
- $holidaylogstatic->date = $obj['date_action'];
+ $holidaylogstatic->id = $obj['rowid'];
+ $holidaylogstatic->date = $obj['date_action'];
$holidaylogstatic->validator = $obj['fk_user_action'];
$holidaylogstatic->employee = $obj['fk_user_update'];
$holidaylogstatic->description = $obj['type_action'];
- $holidaylogstatic->type = $obj['fk_type'];
- $holidaylogstatic->balance_previous = $obj['prev_solde'];
+ $holidaylogstatic->type = $obj['fk_type'];
+ $holidaylogstatic->balance_previous = $obj['prev_solde'];
$holidaylogstatic->balance_new = $obj['new_solde'];
print '';
diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php
index 3684d4d2d7e..19b71cb8cd3 100644
--- a/htdocs/imports/class/import.class.php
+++ b/htdocs/imports/class/import.class.php
@@ -28,21 +28,21 @@
*/
class Import
{
- public $array_import_module;
- public $array_import_perms;
- public $array_import_icon;
- public $array_import_code;
- public $array_import_label;
- public $array_import_tables;
- public $array_import_tables_creator;
- public $array_import_fields;
- public $array_import_fieldshidden;
- public $array_import_entities;
- public $array_import_regex;
- public $array_import_updatekeys;
- public $array_import_examplevalues;
- public $array_import_convertvalue;
- public $array_import_run_sql_after;
+ public $array_import_module;
+ public $array_import_perms;
+ public $array_import_icon;
+ public $array_import_code;
+ public $array_import_label;
+ public $array_import_tables;
+ public $array_import_tables_creator;
+ public $array_import_fields;
+ public $array_import_fieldshidden;
+ public $array_import_entities;
+ public $array_import_regex;
+ public $array_import_updatekeys;
+ public $array_import_examplevalues;
+ public $array_import_convertvalue;
+ public $array_import_run_sql_after;
/**
* @var string Error code (or message)
@@ -55,40 +55,40 @@ class Import
public $errors = array();
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load description int this->array_import_module, this->array_import_fields, ... of an importable dataset
*
* @param User $user Object user making import
* @param string $filter Load a particular dataset only. Index will start to 0.
- * @return int <0 if KO, >0 if OK
+ * @return int <0 if KO, >0 if OK
*/
- public function load_arrays($user, $filter = '')
+ public function load_arrays($user, $filter = '')
{
- // phpcs:enable
+ // phpcs:enable
global $langs, $conf;
dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter);
- $i = 0;
+ $i = 0;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $modulesdir = dolGetModulesDirs();
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ $modulesdir = dolGetModulesDirs();
- // Load list of modules
- foreach ($modulesdir as $dir)
- {
+ // Load list of modules
+ foreach ($modulesdir as $dir)
+ {
$handle = @opendir(dol_osencode($dir));
if (!is_resource($handle)) continue;
@@ -181,14 +181,14 @@ class Import
}
}
}
- closedir($handle);
+ closedir($handle);
}
return 1;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build an import example file.
* Arrays this->array_export_xxx are already loaded for required datatoexport
@@ -199,9 +199,9 @@ class Import
* @param string $datatoimport Dataset to import
* @return string <0 if KO, >0 if OK
*/
- public function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport)
+ public function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport)
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $langs;
$indice = 0;
@@ -239,7 +239,7 @@ class Import
* @param User $user Object user that save
* @return int <0 if KO, >0 if OK
*/
- public function create($user)
+ public function create($user)
{
global $conf;
@@ -277,7 +277,7 @@ class Import
* @param int $id Id of profil to load
* @return int <0 if KO, >0 if OK
*/
- public function fetch($id)
+ public function fetch($id)
{
$sql = 'SELECT em.rowid, em.field, em.label, em.type';
$sql .= ' FROM '.MAIN_DB_PREFIX.'import_model as em';
@@ -313,7 +313,7 @@ class Import
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
- public function delete($user, $notrigger = 0)
+ public function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
diff --git a/htdocs/imports/emptyexample.php b/htdocs/imports/emptyexample.php
index 9c5d8c12a0d..7e7cec1707e 100644
--- a/htdocs/imports/emptyexample.php
+++ b/htdocs/imports/emptyexample.php
@@ -21,7 +21,7 @@
* \brief Show example of import file
*/
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
/**
@@ -32,7 +32,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not rol
*/
function llxHeader()
{
- print 'Build an import example file';
+ print 'Build an import example file';
}
/**
@@ -43,7 +43,7 @@ function llxHeader()
*/
function llxFooter()
{
- print '';
+ print '';
}
require '../main.inc.php';
diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php
index 32d4b223cdb..e9ee3d0bece 100644
--- a/htdocs/imports/import.php
+++ b/htdocs/imports/import.php
@@ -328,7 +328,7 @@ if ($step == 1 || !$datatoimport)
llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
- $head = import_prepare_head($param, 1);
+ $head = import_prepare_head($param, 1);
print dol_get_fiche_head($head, 'step1', $langs->trans("NewImport"), -1);
@@ -358,7 +358,7 @@ if ($step == 1 || !$datatoimport)
print '| ';
print img_object($objimport->array_import_module[$key]['module']->getName(), $objimport->array_import_icon[$key]).' ';
print $objimport->array_import_label[$key];
- print ' | ';
+ print ' | ';
if ($objimport->array_import_perms[$key])
{
print ''.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15x"').'';
@@ -371,9 +371,9 @@ if ($step == 1 || !$datatoimport)
print ' | | '.$langs->trans("NoImportableData").' | ';
}
print ' ';
- print ' ';
+ print '';
- print dol_get_fiche_end();
+ print dol_get_fiche_end();
}
@@ -388,7 +388,7 @@ if ($step == 2 && $datatoimport)
llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
- $head = import_prepare_head($param, 2);
+ $head = import_prepare_head($param, 2);
print dol_get_fiche_head($head, 'step2', $langs->trans("NewImport"), -2);
@@ -440,8 +440,8 @@ if ($step == 2 && $datatoimport)
{
print ' ';
print '| '.img_picto_common($key, $objmodelimport->getPictoForKey($key)).' | ';
- $text = $objmodelimport->getDriverDescForKey($key);
- print ''.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).' | ';
+ $text = $objmodelimport->getDriverDescForKey($key);
+ print ''.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).' | ';
print ''.$langs->trans("DownloadEmptyExample").' | ';
// Action button
print '';
@@ -470,7 +470,7 @@ if ($step == 3 && $datatoimport)
llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
- $head = import_prepare_head($param, 3);
+ $head = import_prepare_head($param, 3);
print dol_get_fiche_head($head, 'step3', $langs->trans("NewImport"), -2);
@@ -517,9 +517,9 @@ if ($step == 3 && $datatoimport)
// Source file format
print ' | | '.$langs->trans("SourceFileFormat").' | ';
print '';
- $text = $objmodelimport->getDriverDescForKey($format);
- print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
- print ' | '.$langs->trans("DownloadEmptyExample").'';
+ $text = $objmodelimport->getDriverDescForKey($format);
+ print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
+ print ' | '.$langs->trans("DownloadEmptyExample").'';
print ' | ';
@@ -535,7 +535,7 @@ if ($step == 3 && $datatoimport)
}
- print ' ';
+ print ' ';
print ' ';
@@ -842,30 +842,30 @@ if ($step == 4 && $datatoimport)
print ' '."\n";
- // List of source fields
- print ''."\n";
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
- print '';
+ // List of source fields
+ print ''."\n";
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
+ print '';
- print '';
- print ''.$langs->trans("SelectImportFields", img_picto('', 'grip_title', '', false, 0, 0, '', '', 0)).' ';
- $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1);
- print '';
- print ' ';
- print '';
+ print '';
+ print ''.$langs->trans("SelectImportFields", img_picto('', 'grip_title', '', false, 0, 0, '', '', 0)).' ';
+ $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1);
+ print '';
+ print ' ';
+ print '';
// Title of array with fields
- print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
- print ' ';
+ print ''; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+ print ' ';
print '';
print '| '.$langs->trans("FieldsInSourceFile").' | ';
print ''.$langs->trans("FieldsInTargetDatabase").' | ';
@@ -978,11 +978,11 @@ if ($step == 4 && $datatoimport)
// Example
if (empty($objimport->array_import_convertvalue[0][$code])) // If source file does not need convertion
{
- if ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.' ';
+ if ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.' ';
} else {
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').' ';
- elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').' ';
- elseif ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.' ';
+ if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').' ';
+ elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').' ';
+ elseif ($example) $htmltext .= $langs->trans("SourceExample").': '.$example.' ';
}
// Format control rule
if (!empty($objimport->array_import_regex[0][$code]))
@@ -1055,13 +1055,13 @@ if ($step == 4 && $datatoimport)
print ' ';
print ' ';
- print ' ';
+ print '';
if ($conf->use_javascript_ajax)
{
- print ''."\n";
+ print "\n";
+ print 'function updateOrder(){'."\n";
+ print 'var left_list = cleanSerialize(jQuery("#left").sortable("serialize" ));'."\n";
+ //print 'var right_list = cleanSerialize(jQuery("#right").sortable("serialize" ));'."\n";
+ print 'var boxorder = \'A:\' + left_list;'."\n";
+ //print 'var boxorder = \'A:\' + left_list + \'-B:\' + right_list;'."\n";
+ //print 'alert(\'boxorder=\' + boxorder);';
+ //print 'var userid = \''.$user->id.'\';'."\n";
+ //print 'var datatoimport = "'.$datatoimport.'";'."\n";
+ // print 'jQuery.ajax({ url: "ajaximport.php?step=4&boxorder=" + boxorder + "&userid=" + userid + "&datatoimport=" + datatoimport,
+ // async: false
+ // });'."\n";
+ // Now reload page
+ print 'var newlocation= \''.$_SERVER["PHP_SELF"].'?step=4'.$param.'&action=saveorder&boxorder=\' + boxorder;'."\n";
+ //print 'alert(newlocation);';
+ print 'window.location.href=newlocation;'."\n";
+ print '}'."\n";
+ print ''."\n";
}
/*
@@ -1126,12 +1126,12 @@ if ($step == 4 && $datatoimport)
print '';
print '';
print '';
- print '';
+ print '';
print '';
- print '';
- print '';
- print '';
- print '';
+ print '';
+ print '';
+ print '';
+ print '';
print '';
print '';
@@ -1189,8 +1189,8 @@ if ($step == 5 && $datatoimport)
require_once $dir.$file;
$obj = new $classname($db, $datatoimport);
if ($model == 'csv') {
- $obj->separator = $separator;
- $obj->enclosure = $enclosure;
+ $obj->separator = $separator;
+ $obj->enclosure = $enclosure;
}
// Load source fields in input file
@@ -1221,13 +1221,13 @@ if ($step == 5 && $datatoimport)
llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
- $head = import_prepare_head($param, 5);
+ $head = import_prepare_head($param, 5);
- print '';
- print '';
- print ''; // step 5
- print ''; // step 5
+ print '';
+ print '';
+ print ''; // step 5
+ print ''; // step 5
print dol_get_fiche_head($head, 'step5', $langs->trans("NewImport"), -2);
@@ -1265,17 +1265,17 @@ if ($step == 5 && $datatoimport)
// Source file format
print '| '.$langs->trans("SourceFileFormat").' | ';
print '';
- $text = $objmodelimport->getDriverDescForKey($format);
- print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
+ $text = $objmodelimport->getDriverDescForKey($format);
+ print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
print ' | ';
// Separator and enclosure
if ($model == 'csv') {
- print '| '.$langs->trans("CsvOptions").' | ';
- print '';
- print $langs->trans("Separator").' : '.dol_escape_htmltag($separator);
- print ' '.$langs->trans("Enclosure").' : '.dol_escape_htmltag($enclosure);
- print ' | ';
+ print '| '.$langs->trans("CsvOptions").' | ';
+ print '';
+ print $langs->trans("Separator").' : '.dol_escape_htmltag($separator);
+ print ' '.$langs->trans("Enclosure").' : '.dol_escape_htmltag($enclosure);
+ print ' | ';
}
// File to import
@@ -1283,10 +1283,10 @@ if ($step == 5 && $datatoimport)
print '';
$modulepart = 'import';
$relativepath = GETPOST('filetoimport');
- print '';
- print $filetoimport;
- print '';
- print ' | ';
+ print '';
+ print $filetoimport;
+ print '';
+ print '';
// Total lines in source file
print '| ';
@@ -1301,22 +1301,22 @@ if ($step == 5 && $datatoimport)
print ' | ';
if ($action == 'launchsimu')
{
- print '';
- print '';
+ print '';
+ print '';
} else {
- print '';
- print $form->textwithpicto("", $langs->trans("SetThisValueTo2ToExcludeFirstLine"));
+ print '';
+ print $form->textwithpicto("", $langs->trans("SetThisValueTo2ToExcludeFirstLine"));
}
print ' - ';
if ($action == 'launchsimu')
{
- print '';
- print '';
+ print '';
+ print '';
} else {
- print '';
- print $form->textwithpicto("", $langs->trans("KeepEmptyToGoToEndOfFile"));
+ print '';
+ print $form->textwithpicto("", $langs->trans("KeepEmptyToGoToEndOfFile"));
}
- if ($action == 'launchsimu') print ' '.$langs->trans("Modify").'';
+ if ($action == 'launchsimu') print ' '.$langs->trans("Modify").'';
print ' | ';
// Keys for data UPDATE (not INSERT of new data)
@@ -1336,7 +1336,7 @@ if ($step == 5 && $datatoimport)
print ' '.$langs->trans("Modify").'';
} else {
if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0]))
- { //TODO dropdown UL is created inside nested SPANS
+ { //TODO dropdown UL is created inside nested SPANS
print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%');
print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt"));
} else {
@@ -1421,186 +1421,186 @@ if ($step == 5 && $datatoimport)
print ' ';
print '';
- print dol_get_fiche_end();
+ print dol_get_fiche_end();
- if ($action != 'launchsimu')
- {
- // Show import id
- print ' ';
- print $langs->trans("NowClickToTestTheImport", $langs->transnoentitiesnoconv("RunSimulateImportFile")).' ';
- print ' ';
+ if ($action != 'launchsimu')
+ {
+ // Show import id
+ print ' ';
+ print $langs->trans("NowClickToTestTheImport", $langs->transnoentitiesnoconv("RunSimulateImportFile")).' ';
+ print ' ';
- // Actions
- print '';
- } else {
- // Launch import
- $arrayoferrors = array();
- $arrayofwarnings = array();
- $maxnboferrors = empty($conf->global->IMPORT_MAX_NB_OF_ERRORS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_ERRORS;
- $maxnbofwarnings = empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_WARNINGS;
- $nboferrors = 0;
- $nbofwarnings = 0;
+ // Actions
+ print '';
+ } else {
+ // Launch import
+ $arrayoferrors = array();
+ $arrayofwarnings = array();
+ $maxnboferrors = empty($conf->global->IMPORT_MAX_NB_OF_ERRORS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_ERRORS;
+ $maxnbofwarnings = empty($conf->global->IMPORT_MAX_NB_OF_WARNINGS) ? 50 : $conf->global->IMPORT_MAX_NB_OF_WARNINGS;
+ $nboferrors = 0;
+ $nbofwarnings = 0;
- $importid = dol_print_date(dol_now(), '%Y%m%d%H%M%S');
+ $importid = dol_print_date(dol_now(), '%Y%m%d%H%M%S');
- //var_dump($array_match_file_to_database);
+ //var_dump($array_match_file_to_database);
- $db->begin();
+ $db->begin();
- // Open input file
- $nbok = 0;
- $pathfile = $conf->import->dir_temp.'/'.$filetoimport;
- $result = $obj->import_open_file($pathfile, $langs);
- if ($result > 0)
- {
- global $tablewithentity_cache;
- $tablewithentity_cache = array();
- $sourcelinenb = 0; $endoffile = 0;
+ // Open input file
+ $nbok = 0;
+ $pathfile = $conf->import->dir_temp.'/'.$filetoimport;
+ $result = $obj->import_open_file($pathfile, $langs);
+ if ($result > 0)
+ {
+ global $tablewithentity_cache;
+ $tablewithentity_cache = array();
+ $sourcelinenb = 0; $endoffile = 0;
- // Loop on each input file record
- while (($sourcelinenb < $nboflines) && !$endoffile)
- {
- $sourcelinenb++;
- // Read line and store it into $arrayrecord
- //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb);
- $arrayrecord = $obj->import_read_record();
- if ($arrayrecord === false)
- {
+ // Loop on each input file record
+ while (($sourcelinenb < $nboflines) && !$endoffile)
+ {
+ $sourcelinenb++;
+ // Read line and store it into $arrayrecord
+ //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb);
+ $arrayrecord = $obj->import_read_record();
+ if ($arrayrecord === false)
+ {
$arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines. Ensure the complete string is delimited correctly when there is a separator character in the text string.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES');
- $endoffile++;
- continue;
- }
- if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue;
- if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break;
+ $endoffile++;
+ continue;
+ }
+ if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue;
+ if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break;
- // Run import
- $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys);
+ // Run import
+ $result = $obj->import_insert($arrayrecord, $array_match_file_to_database, $objimport, count($fieldssource), $importid, $updatekeys);
- if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors;
- if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings;
- if (!count($obj->errors) && !count($obj->warnings)) $nbok++;
- }
- // Close file
- $obj->import_close_file();
- } else {
- print $langs->trans("ErrorFailedToOpenFile", $pathfile);
- }
+ if (count($obj->errors)) $arrayoferrors[$sourcelinenb] = $obj->errors;
+ if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb] = $obj->warnings;
+ if (!count($obj->errors) && !count($obj->warnings)) $nbok++;
+ }
+ // Close file
+ $obj->import_close_file();
+ } else {
+ print $langs->trans("ErrorFailedToOpenFile", $pathfile);
+ }
- $error = 0;
+ $error = 0;
- // Run the sql after import if defined
- //var_dump($objimport->array_import_run_sql_after[0]);
- if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
- {
- $i = 0;
- foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
- {
- $i++;
- $resqlafterimport = $db->query($sqlafterimport);
- if (!$resqlafterimport)
- {
- $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
- $error++;
- }
- }
- }
+ // Run the sql after import if defined
+ //var_dump($objimport->array_import_run_sql_after[0]);
+ if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
+ {
+ $i = 0;
+ foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
+ {
+ $i++;
+ $resqlafterimport = $db->query($sqlafterimport);
+ if (!$resqlafterimport)
+ {
+ $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
+ $error++;
+ }
+ }
+ }
- $db->rollback(); // We force rollback because this was just a simulation.
+ $db->rollback(); // We force rollback because this was just a simulation.
- // Show OK
- if (!count($arrayoferrors) && !count($arrayofwarnings)) {
- print ''.img_picto($langs->trans("OK"), 'tick').' '.$langs->trans("NoError").'
';
+ // Show OK
+ if (!count($arrayoferrors) && !count($arrayofwarnings)) {
+ print ''.img_picto($langs->trans("OK"), 'tick').' '.$langs->trans("NoError").'
';
print $langs->trans("NbInsert", $obj->nbinsert).' ';
print $langs->trans("NbUpdate", $obj->nbupdate).'
';
} else print $langs->trans("NbOfLinesOK", $nbok).'
';
- // Show Errors
- //var_dump($arrayoferrors);
- if (count($arrayoferrors))
- {
- print img_error().' '.$langs->trans("ErrorsOnXLines", count($arrayoferrors)).' ';
- print '';
- foreach ($arrayoferrors as $key => $val)
- {
- $nboferrors++;
- if ($nboferrors > $maxnboferrors)
- {
- print $langs->trans("TooMuchErrors", (count($arrayoferrors) - $nboferrors))." ";
- break;
- }
- print '* '.$langs->trans("Line").' '.$key.' ';
- foreach ($val as $i => $err)
- {
- print ' > '.$err['lib'].' ';
- }
- }
- print ' | ';
- print ' ';
- }
+ // Show Errors
+ //var_dump($arrayoferrors);
+ if (count($arrayoferrors))
+ {
+ print img_error().' '.$langs->trans("ErrorsOnXLines", count($arrayoferrors)).' ';
+ print '';
+ foreach ($arrayoferrors as $key => $val)
+ {
+ $nboferrors++;
+ if ($nboferrors > $maxnboferrors)
+ {
+ print $langs->trans("TooMuchErrors", (count($arrayoferrors) - $nboferrors))." ";
+ break;
+ }
+ print '* '.$langs->trans("Line").' '.$key.' ';
+ foreach ($val as $i => $err)
+ {
+ print ' > '.$err['lib'].' ';
+ }
+ }
+ print ' | ';
+ print ' ';
+ }
- // Show Warnings
- //var_dump($arrayoferrors);
- if (count($arrayofwarnings))
- {
- print img_warning().' '.$langs->trans("WarningsOnXLines", count($arrayofwarnings)).' ';
- print '';
- foreach ($arrayofwarnings as $key => $val)
- {
- $nbofwarnings++;
- if ($nbofwarnings > $maxnbofwarnings)
- {
- print $langs->trans("TooMuchWarnings", (count($arrayofwarnings) - $nbofwarnings))." ";
- break;
- }
- print ' * '.$langs->trans("Line").' '.$key.' ';
- foreach ($val as $i => $err)
- {
- print ' > '.$err['lib'].' ';
- }
- }
- print ' | ';
- print ' ';
- }
+ // Show Warnings
+ //var_dump($arrayoferrors);
+ if (count($arrayofwarnings))
+ {
+ print img_warning().' '.$langs->trans("WarningsOnXLines", count($arrayofwarnings)).' ';
+ print '';
+ foreach ($arrayofwarnings as $key => $val)
+ {
+ $nbofwarnings++;
+ if ($nbofwarnings > $maxnbofwarnings)
+ {
+ print $langs->trans("TooMuchWarnings", (count($arrayofwarnings) - $nbofwarnings))." ";
+ break;
+ }
+ print ' * '.$langs->trans("Line").' '.$key.' ';
+ foreach ($val as $i => $err)
+ {
+ print ' > '.$err['lib'].' ';
+ }
+ }
+ print ' | ';
+ print ' ';
+ }
- // Show import id
- $importid = dol_print_date(dol_now(), '%Y%m%d%H%M%S');
+ // Show import id
+ $importid = dol_print_date(dol_now(), '%Y%m%d%H%M%S');
- print '';
- print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).' ';
- if (empty($nboferrors)) print $langs->trans("DataLoadedWithId", $importid).' ';
- print ' ';
+ print '';
+ print ''.$langs->trans("NowClickToRunTheImport", $langs->transnoentitiesnoconv("RunImportFile")).' ';
+ if (empty($nboferrors)) print $langs->trans("DataLoadedWithId", $importid).' ';
+ print ' ';
- print ' ';
+ print ' ';
- // Actions
- print '';
+ }
- print '';
+ print '';
}
@@ -1619,8 +1619,8 @@ if ($step == 6 && $datatoimport)
require_once $dir.$file;
$obj = new $classname($db, $datatoimport);
if ($model == 'csv') {
- $obj->separator = $separator;
- $obj->enclosure = $enclosure;
+ $obj->separator = $separator;
+ $obj->enclosure = $enclosure;
}
// Load source fields in input file
@@ -1650,7 +1650,7 @@ if ($step == 6 && $datatoimport)
llxHeader('', $langs->trans("NewImport"), 'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
- $head = import_prepare_head($param, 6);
+ $head = import_prepare_head($param, 6);
print dol_get_fiche_head($head, 'step6', $langs->trans("NewImport"), -1);
@@ -1688,29 +1688,29 @@ if ($step == 6 && $datatoimport)
// Source file format
print '| '.$langs->trans("SourceFileFormat").' | ';
print '';
- $text = $objmodelimport->getDriverDescForKey($format);
- print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
+ $text = $objmodelimport->getDriverDescForKey($format);
+ print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text);
print ' | ';
// Separator and enclosure
if ($model == 'csv') {
- print '| '.$langs->trans("CsvOptions").' | ';
- print '';
- print $langs->trans("Separator").' : ';
- print htmlentities($separator);
- print ' '.$langs->trans("Enclosure").' : ';
- print htmlentities($enclosure);
- print ' | ';
+ print '| '.$langs->trans("CsvOptions").' | ';
+ print '';
+ print $langs->trans("Separator").' : ';
+ print htmlentities($separator);
+ print ' '.$langs->trans("Enclosure").' : ';
+ print htmlentities($enclosure);
+ print ' | ';
}
// File to import
print '| '.$langs->trans("FileToImport").' | ';
print '';
$modulepart = 'import';
- $relativepath = GETPOST('filetoimport');
- print '';
- print $filetoimport;
- print '';
+ $relativepath = GETPOST('filetoimport');
+ print '';
+ print $filetoimport;
+ print '';
print ' | ';
// Nb of fields
@@ -1731,7 +1731,7 @@ if ($step == 6 && $datatoimport)
print '| ';
print $langs->trans("EndAtLineNb");
print ' | ';
- print '';
+ print '';
print ' | ';
print ' ';
@@ -1824,8 +1824,8 @@ if ($step == 6 && $datatoimport)
$result = $obj->import_open_file($pathfile, $langs);
if ($result > 0)
{
- global $tablewithentity_cache;
- $tablewithentity_cache = array();
+ global $tablewithentity_cache;
+ $tablewithentity_cache = array();
$sourcelinenb = 0; $endoffile = 0;
while ($sourcelinenb < $nboflines && !$endoffile)
@@ -1856,30 +1856,30 @@ if ($step == 6 && $datatoimport)
if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors.
else {
- $error = 0;
+ $error = 0;
// Run the sql after import if defined
- //var_dump($objimport->array_import_run_sql_after[0]);
- if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
- {
- $i = 0;
- foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
- {
- $i++;
- $resqlafterimport = $db->query($sqlafterimport);
- if (!$resqlafterimport)
- {
- $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
- $error++;
- }
- }
- }
+ //var_dump($objimport->array_import_run_sql_after[0]);
+ if (!empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0]))
+ {
+ $i = 0;
+ foreach ($objimport->array_import_run_sql_after[0] as $sqlafterimport)
+ {
+ $i++;
+ $resqlafterimport = $db->query($sqlafterimport);
+ if (!$resqlafterimport)
+ {
+ $arrayoferrors['none'][] = array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport));
+ $error++;
+ }
+ }
+ }
- if (!$error) $db->commit(); // We can commit if no errors.
- else $db->rollback();
+ if (!$error) $db->commit(); // We can commit if no errors.
+ else $db->rollback();
}
- print dol_get_fiche_end();
+ print dol_get_fiche_end();
// Show result
@@ -1918,17 +1918,17 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
$height = '24px';
- if ($key == 'none') {
- //stop multiple duplicate ids with no number
- print "\n\n\n";
- print ' '."\n";
- print ' '."\n";
- } else {
- print "\n\n\n";
- print ''."\n";
+ if ($key == 'none') {
+ //stop multiple duplicate ids with no number
+ print "\n\n\n";
+ print ' '."\n";
+ print ' '."\n";
+ } else {
+ print "\n\n\n";
+ print ''."\n";
- print ' '."\n";
- }
+ print ''."\n";
+ }
if ($pos && $pos > count($fieldssource)) // No fields
{
@@ -1962,8 +1962,8 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '')
$example = $fieldssource[$pos]['example1'];
if ($example)
{
- if (!utf8_check($example)) $example = utf8_encode($example);
- print ' ('.$example.')';
+ if (!utf8_check($example)) $example = utf8_encode($example);
+ print ' ('.$example.')';
}
print '';
print '';
diff --git a/htdocs/imports/index.php b/htdocs/imports/index.php
index bc68b53cfd0..4c556325b05 100644
--- a/htdocs/imports/index.php
+++ b/htdocs/imports/index.php
@@ -51,7 +51,7 @@ print ' ';
print '';
if (count($import->array_import_code))
{
- print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import');
+ print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import');
}
print ' ';
print ' ';
diff --git a/htdocs/index.php b/htdocs/index.php
index 952ff525258..5290e2623a2 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -295,7 +295,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
$class = $classes[$val];
// Search in cache if load_state_board is already realized
$classkeyforcache = $class;
- if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
+ if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache]))
{
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 267e1629f36..bd34a0ac30c 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -68,10 +68,10 @@ print ' '.$langs->trans("WarningBrowserTooOld")." \n";
+ $tmp = getBrowserInfo($_SERVER["HTTP_USER_AGENT"]);
+ $browserversion = $tmp['browserversion'];
+ $browsername = $tmp['browsername'];
+ if ($browsername == 'ie' && $browserversion < 7) print ' '.$langs->trans("WarningBrowserTooOld")." \n";
}
@@ -84,8 +84,8 @@ if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) // M
$checksok = 0; // 0=error, 1=warning
} elseif (versioncompare(versionphparray(), $arrayphpminversionwarning) < 0) // Minimum supported (warning if lower)
{
- print ' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
- $checksok = 0; // 0=error, 1=warning
+ print ' '.$langs->trans("ErrorPHPVersionTooLow", versiontostring($arrayphpminversionwarning));
+ $checksok = 0; // 0=error, 1=warning
} else {
print ' '.$langs->trans("PHPVersion")." ".versiontostring(versionphparray());
}
@@ -129,19 +129,19 @@ if (!function_exists("imagecreate"))
// Check if Curl supported
if (!function_exists("curl_init"))
{
- $langs->load("errors");
- print ' '.$langs->trans("ErrorPHPDoesNotSupportCurl")." \n";
- // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ $langs->load("errors");
+ print ' '.$langs->trans("ErrorPHPDoesNotSupportCurl")." \n";
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
} else {
- print ' '.$langs->trans("PHPSupportCurl")." \n";
+ print ' '.$langs->trans("PHPSupportCurl")." \n";
}
// Check if PHP calendar extension is available
if (!function_exists("easter_date"))
{
- print ' '.$langs->trans("ErrorPHPDoesNotSupportCalendar")." \n";
+ print ' '.$langs->trans("ErrorPHPDoesNotSupportCalendar")." \n";
} else {
- print ' '.$langs->trans("PHPSupportCalendar")." \n";
+ print ' '.$langs->trans("PHPSupportCalendar")." \n";
}
@@ -161,11 +161,11 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
{
if (!function_exists("locale_get_primary_language") || !function_exists("locale_get_region"))
{
- $langs->load("errors");
- print ' '.$langs->trans("ErrorPHPDoesNotSupportIntl")." \n";
- // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ $langs->load("errors");
+ print ' '.$langs->trans("ErrorPHPDoesNotSupportIntl")." \n";
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
} else {
- print ' '.$langs->trans("PHPSupportIntl")." \n";
+ print ' '.$langs->trans("PHPSupportIntl")." \n";
}
}
@@ -307,35 +307,35 @@ if (!file_exists($conffile))
{
if (!file_exists($dolibarr_main_document_root."/core/lib/admin.lib.php"))
{
- print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file. '."\n";
- dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING);
+ print 'A '.$conffiletoshow.' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.' that seems wrong. Try to fix or remove the '.$conffiletoshow.' file. '."\n";
+ dol_syslog("A '".$conffiletoshow."' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root." that seems wrong. Try to fix or remove the '".$conffiletoshow."' file.", LOG_WARNING);
} else {
- require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
+ require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
- // If password is encoded, we decode it
- if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
- {
- require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
- if (preg_match('/crypted:/i', $dolibarr_main_db_pass))
- {
- $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
- $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
- }
+ // If password is encoded, we decode it
+ if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass))
+ {
+ require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
+ if (preg_match('/crypted:/i', $dolibarr_main_db_pass))
+ {
+ $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted
+ $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ } else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
+ }
- // $conf already created in inc.php
- $conf->db->type = $dolibarr_main_db_type;
- $conf->db->host = $dolibarr_main_db_host;
- $conf->db->port = $dolibarr_main_db_port;
- $conf->db->name = $dolibarr_main_db_name;
- $conf->db->user = $dolibarr_main_db_user;
- $conf->db->pass = $dolibarr_main_db_pass;
- $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
- if ($db->connected && $db->database_selected)
- {
- $ok = true;
- }
- }
+ // $conf already created in inc.php
+ $conf->db->type = $dolibarr_main_db_type;
+ $conf->db->host = $dolibarr_main_db_host;
+ $conf->db->port = $dolibarr_main_db_port;
+ $conf->db->name = $dolibarr_main_db_name;
+ $conf->db->user = $dolibarr_main_db_user;
+ $conf->db->pass = $dolibarr_main_db_pass;
+ $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
+ if ($db->connected && $db->database_selected)
+ {
+ $ok = true;
+ }
+ }
}
}
@@ -361,8 +361,8 @@ if (!file_exists($conffile))
// Show title
if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL))
{
- print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - ';
- print $langs->trans("VersionProgram").': '.DOL_VERSION.'';
+ print $langs->trans("VersionLastUpgrade").': '.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).' - ';
+ print $langs->trans("VersionProgram").': '.DOL_VERSION.'';
//print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
print ' ';
print ' ';
@@ -373,19 +373,19 @@ if (!file_exists($conffile))
$foundrecommandedchoice = 0;
- $available_choices = array();
- $notavailable_choices = array();
+ $available_choices = array();
+ $notavailable_choices = array();
- if (empty($dolibarr_main_db_host)) // This means install process was not run
- {
- $foundrecommandedchoice = 1; // To show only once
- }
+ if (empty($dolibarr_main_db_host)) // This means install process was not run
+ {
+ $foundrecommandedchoice = 1; // To show only once
+ }
- // Show line of first install choice
- $choice = ''."\n";
- $choice .= '| '.$langs->trans("FreshInstall").'';
+ // Show line of first install choice
+ $choice = ' | '."\n";
+ $choice .= '| '.$langs->trans("FreshInstall").'';
$choice .= ' | ';
- $choice .= '';
+ $choice .= ' | ';
$choice .= $langs->trans("FreshInstallDesc");
if (empty($dolibarr_main_db_host)) // This means install process was not run
{
@@ -395,23 +395,23 @@ if (!file_exists($conffile))
// ';
}
- $choice .= ' | ';
- $choice .= '';
+ $choice .= ' | ';
+ $choice .= '';
if ($allowinstall)
{
- $choice .= ''.$langs->trans("Start").'';
+ $choice .= ''.$langs->trans("Start").'';
} else {
$choice .= ($foundrecommandedchoice ? '' : '').$langs->trans("InstallNotAllowed").($foundrecommandedchoice ? '' : '');
}
- $choice .= ' | '."\n";
- $choice .= ' '."\n";
+ $choice .= ''."\n";
+ $choice .= ''."\n";
- $positionkey = ($foundrecommandedchoice ? 999 : 0);
- if ($allowinstall) {
- $available_choices[$positionkey] = $choice;
- } else {
- $notavailable_choices[$positionkey] = $choice;
- }
+ $positionkey = ($foundrecommandedchoice ? 999 : 0);
+ if ($allowinstall) {
+ $available_choices[$positionkey] = $choice;
+ } else {
+ $notavailable_choices[$positionkey] = $choice;
+ }
// Show upgrade lines
$allowupgrade = true;
@@ -445,64 +445,64 @@ if (!file_exists($conffile))
$count = 0;
foreach ($migrationscript as $migarray)
{
- $choice = '';
+ $choice = '';
$count++;
- $recommended_choice = false;
- $version = DOL_VERSION;
+ $recommended_choice = false;
+ $version = DOL_VERSION;
$versionfrom = $migarray['from'];
- $versionto = $migarray['to'];
- $versionarray = preg_split('/[\.-]/', $version);
- $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
- $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
- // Define string newversionxxx that are used for text to show
- $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
- $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
- $newversionfrombis = '';
- if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1
- {
- $newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
- }
+ $versionto = $migarray['to'];
+ $versionarray = preg_split('/[\.-]/', $version);
+ $dolibarrversionfromarray = preg_split('/[\.-]/', $versionfrom);
+ $dolibarrversiontoarray = preg_split('/[\.-]/', $versionto);
+ // Define string newversionxxx that are used for text to show
+ $newversionfrom = preg_replace('/(\.[0-9]+)$/i', '.*', $versionfrom);
+ $newversionto = preg_replace('/(\.[0-9]+)$/i', '.*', $versionto);
+ $newversionfrombis = '';
+ if (versioncompare($dolibarrversiontoarray, $versionarray) < -2) // From x.y.z -> x.y.z+1
+ {
+ $newversionfrombis = ' '.$langs->trans("or").' '.$versionto;
+ }
- if ($ok)
- {
- if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known
- {
- // Now we check if this is the first qualified choice
- if ($allowupgrade && empty($foundrecommandedchoice) &&
- (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
- )
- {
- $foundrecommandedchoice = 1; // To show only once
- $recommended_choice = true;
- }
- } else {
- // We cannot recommend a choice.
- // A version of install may be known, but we need last upgrade.
- }
- }
+ if ($ok)
+ {
+ if (count($dolibarrlastupgradeversionarray) >= 2) // If database access is available and last upgrade version is known
+ {
+ // Now we check if this is the first qualified choice
+ if ($allowupgrade && empty($foundrecommandedchoice) &&
+ (versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 || versioncompare($dolibarrversiontoarray, $versionarray) < -2)
+ )
+ {
+ $foundrecommandedchoice = 1; // To show only once
+ $recommended_choice = true;
+ }
+ } else {
+ // We cannot recommend a choice.
+ // A version of install may be known, but we need last upgrade.
+ }
+ }
- $choice .= "\n".''."\n";
- $choice .= '';
- $choice .= ''.$langs->trans("Upgrade").' '.$newversionfrom.$newversionfrombis.' -> '.$newversionto.' | ';
- $choice .= '';
- $choice .= $langs->trans("UpgradeDesc");
+ $choice .= "\n".''."\n";
+ $choice .= ' | ';
+ $choice .= ''.$langs->trans("Upgrade").' '.$newversionfrom.$newversionfrombis.' -> '.$newversionto.' | ';
+ $choice .= '';
+ $choice .= $langs->trans("UpgradeDesc");
- if ($recommended_choice)
- {
- $choice .= ' ';
- //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
- $choice .= '';
- $choice .= ' '.$langs->trans("InstallChoiceSuggested").' ';
- if ($count < count($migarray)) // There are other choices after
- {
- print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
- }
- $choice .= ' ';
- }
+ if ($recommended_choice)
+ {
+ $choice .= ' ';
+ //print $langs->trans("InstallChoiceRecommanded",DOL_VERSION,$conf->global->MAIN_VERSION_LAST_UPGRADE);
+ $choice .= '';
+ $choice .= ' '.$langs->trans("InstallChoiceSuggested").' ';
+ if ($count < count($migarray)) // There are other choices after
+ {
+ print $langs->trans("MigrateIsDoneStepByStep", DOL_VERSION);
+ }
+ $choice .= ' ';
+ }
- $choice .= ' | ';
- $choice .= '';
+ $choice .= ' | ';
+ $choice .= '';
if ($allowupgrade)
{
$disabled = false;
@@ -515,22 +515,22 @@ if (!file_exists($conffile))
$foundrecommandedchoice = 2;
}
if ($disabled)
- {
- $choice .= ''.$langs->trans("NotYetAvailable").'';
- } else {
- $choice .= ''.$langs->trans("Start").'';
- }
+ {
+ $choice .= ''.$langs->trans("NotYetAvailable").'';
+ } else {
+ $choice .= ''.$langs->trans("Start").'';
+ }
} else {
- $choice .= $langs->trans("NotAvailable");
+ $choice .= $langs->trans("NotAvailable");
}
- $choice .= ' | ';
- $choice .= ' '."\n";
+ $choice .= '';
+ $choice .= ''."\n";
- if ($allowupgrade) {
- $available_choices[$count] = $choice;
- } else {
- $notavailable_choices[$count] = $choice;
- }
+ if ($allowupgrade) {
+ $available_choices[$count] = $choice;
+ } else {
+ $notavailable_choices[$count] = $choice;
+ }
}
// If there is no choice at all, we show all of them.
@@ -540,32 +540,32 @@ if (!file_exists($conffile))
$notavailable_choices = array();
}
- // Array of install choices
+ // Array of install choices
krsort($available_choices, SORT_NATURAL);
- print"\n";
- print '
';
- foreach ($available_choices as $choice) {
- print $choice;
- }
+ print"\n";
+ print '';
+ foreach ($available_choices as $choice) {
+ print $choice;
+ }
- print ' '."\n";
+ print ' '."\n";
- if (count($notavailable_choices)) {
- print '
';
- print '> '.$langs->trans('ShowNotAvailableOptions').'...';
- print ' ';
+ if (count($notavailable_choices)) {
+ print '
';
+ print '> '.$langs->trans('ShowNotAvailableOptions').'...';
+ print ' ';
- print '';
- print " \n";
- print ' ';
- foreach ($notavailable_choices as $choice) {
- print $choice;
- }
+ print '';
+ print " \n";
+ print ' ';
+ foreach ($notavailable_choices as $choice) {
+ print $choice;
+ }
- print ' '."\n";
- print ' ';
- }
- }
+ print ' '."\n";
+ print ' ';
+ }
+ }
}
print ''."\n";
- else print ''."\n";
- if ($jQueryUiCustomPath) print ''."\n";
- else print ''."\n";
+ print ''."\n";
+ if ($jQueryCustomPath) print ''."\n";
+ else print ''."\n";
+ if ($jQueryUiCustomPath) print ''."\n";
+ else print ''."\n";
- print ''.$langs->trans("DolibarrSetup").''."\n";
- print ''."\n";
+ print ''.$langs->trans("DolibarrSetup").''."\n";
+ print ''."\n";
- print ''."\n";
+ print ''."\n";
- print '';
- print '  ';
- print DOL_VERSION;
- print ' ';
+ print '';
+ print '  ';
+ print DOL_VERSION;
+ print ' ';
- print ''.$langs->trans("DolibarrSetup");
- if ($subtitle) {
- print ' - '.$subtitle;
- }
- print ''."\n";
+ print ''.$langs->trans("DolibarrSetup");
+ if ($subtitle) {
+ print ' - '.$subtitle;
+ }
+ print ''."\n";
- print ''."\n";
- print ''."\n";
- print ''."\n";
+ print ''."\n";
+ print ''."\n";
+ print ''."\n";
- print ''."\n";
+ print ''."\n";
- print ''."\n";
+ print '| '."\n";
}
/**
@@ -423,52 +423,52 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
*/
function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0)
{
- global $conf, $langs;
+ global $conf, $langs;
- $langs->load("main");
- $langs->load("other");
- $langs->load("admin");
+ $langs->load("main");
+ $langs->load("other");
+ $langs->load("admin");
- print ' | '."\n";
- print ' | '."\n";
+ print ' | '."\n";
+ print ' | '."\n";
- if (!$nonext || ($nonext == '2'))
- {
- print '';
+ if ($withpleasewait) print ''.$langs->trans("NextStepMightLastALongTime").' '.$langs->trans("PleaseBePatient").' ';
+ }
+ if ($setuplang)
+ {
+ print '';
+ }
- print ''."\n";
+ print ''."\n";
- // If there is some logs in buffer to show
- if (isset($conf->logbuffer) && count($conf->logbuffer))
- {
- print "\n";
- print "\n";
- print "\n";
- }
+ // If there is some logs in buffer to show
+ if (isset($conf->logbuffer) && count($conf->logbuffer))
+ {
+ print "\n";
+ print "\n";
+ print "\n";
+ }
- print ''."\n";
- print ''."\n";
+ print ' |