diff --git a/ChangeLog b/ChangeLog index c9af73628a3..6a076df6cfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,6 +105,8 @@ For users: - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. - Fix: Salary payments are not reflected on the reporting sheets +- Fix: Unsubscribe emailing not working +- Fix: Trigger on create category call failed because user is not passed on card ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: @@ -236,9 +238,9 @@ Fix: Link product, In list view and label product. Fix: visible task into area "time" for "My task" must limit task to tasks i am assigned to. Fix: When disabled, all fields to add time into task line must be disabled. Fix: Missing include files.lib.php in some pages that use dol_delete_recursive -Fix: Missing include files.lib.php in some pages ti use dol_delete_recursive. Fix: [ bug #1558 ] Product/service edit page title shows new Ref instead of old ref. Fix: [ bug #1553 ] Saving User displays setup removes menu. +Fix: [ bug #1544 ] Can remove date from invoice ***** ChangeLog for 3.5.4 compared to 3.5.3 ***** Fix: Hide title of event when agenda module disabled. diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 55e7b54031e..0b06a3d0daa 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,5 +1,5 @@ * Copyright (C) 2013-2014 Alexandre Spangaro * Copyright (C) 2014 Florian Henry @@ -34,7 +34,7 @@ if (! $res && file_exists("../../../main.inc.php")) $res = @include ("../../../main.inc.php"); if (! $res) die("Include of main fails"); - + // Class dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/date.lib.php"); @@ -73,13 +73,13 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - + /* * view */ - + print '

'; - + print ''; print ''; print ''; @@ -88,13 +88,13 @@ if ($resql) { print ''; print ''; print ''; - + $var = True; - + while ( $i < min($num, 250) ) { $obj = $db->fetch_object($resql); $var = ! $var; - + $compta_prodsell = $obj->accountancy_code_sell; if (empty($compta_prodsell)) { if ($obj->product_type == 0) @@ -102,7 +102,7 @@ if ($resql) { else $compta_prodsell = (! empty($conf->global->COMPTA_SERVICE_SOLD_ACCOUNT) ? $conf->global->COMPTA_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); } - + $compta_prodbuy = $obj->accountancy_code_buy; if (empty($compta_prodbuy)) { if ($obj->product_type == 0) @@ -110,12 +110,12 @@ if ($resql) { else $compta_prodbuy = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); } - + $product_static = new Product($db); - + print ""; // Ref produit - $product_static->ref = $objp->p . ref; + $product_static->ref = $objp->ref; $product_static->id = $objp->rowid; $product_static->type = $objp->type; print ''; print ''; print ''; - + print ''; print ''; - + print ''; print ''; - + print "\n"; $i ++; } diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 08d195aedcf..070f9a8071a 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -24,10 +24,10 @@ */ /** - * \class AccountancySystem - * \brief Classe to manage accountancy systems + * Class to manage accountancy systems */ -class AccountancySystem { +class AccountancySystem +{ var $db; var $error; var $rowid; @@ -37,7 +37,7 @@ class AccountancySystem { var $label; var $account_number; var $account_parent; - + /** * Constructor * @@ -46,7 +46,7 @@ class AccountancySystem { function __construct($db) { $this->db = $db; } - + /** * Insert accountancy system name into database * @@ -55,16 +55,16 @@ class AccountancySystem { */ function create($user) { $now = dol_now(); - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system"; $sql .= " (date_creation, fk_user_author, numero,intitule)"; $sql .= " VALUES (" . $this->db->idate($now) . "," . $user->id . ",'" . $this->numero . "','" . $this->intitule . "')"; - + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_system"); - + if ($id > 0) { $this->id = $id; $result = $this->id; @@ -78,7 +78,7 @@ class AccountancySystem { $this->error = "AccountancySystem::Create Erreur $result"; dol_syslog($this->error, LOG_ERR); } - + return $result; } } \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 34c23cb0a51..4c54e609caf 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -24,10 +24,10 @@ */ /** - * \class AccountingAccount - * \brief Classe permettant la gestion des comptes generaux de compta + * Classe permettant la gestion des comptes generaux de compta */ -class AccountingAccount { +class AccountingAccount +{ var $db; var $id; var $rowid; @@ -41,7 +41,7 @@ class AccountingAccount { var $fk_user_author; var $fk_user_modif; var $active; - + /** * \brief Constructeur de la classe * \param DB handler acces base de donnees @@ -49,11 +49,11 @@ class AccountingAccount { */ function __construct($db, $rowid = '') { $this->db = $db; - + if ($rowid != '') return $this->fetch($rowid); } - + /** * \brief Load record in memory */ @@ -65,7 +65,7 @@ class AccountingAccount { } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - + dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -74,7 +74,7 @@ class AccountingAccount { return null; } } - + $this->id = $obj->rowid; $this->rowid = $obj->rowid; $this->datec = $obj->datec; @@ -88,10 +88,10 @@ class AccountingAccount { $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; $this->active = $obj->active; - + return $obj->rowid; } - + /** * \brief insert line in accountingaccount * \param user utilisateur qui effectue l'insertion @@ -99,7 +99,7 @@ class AccountingAccount { function create($user, $notrigger = 0) { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->fk_pcg_version)) $this->fk_pcg_version = trim($this->fk_pcg_version); @@ -117,13 +117,13 @@ class AccountingAccount { $this->fk_user_author = trim($this->fk_user_author); if (isset($this->active)) $this->active = trim($this->active); - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accountingaccount("; - + $sql .= "datec"; $sql .= ", entity"; $sql .= ", fk_pcg_version"; @@ -134,9 +134,9 @@ class AccountingAccount { $sql .= ", label"; $sql .= ", fk_user_author"; $sql .= ", active"; - + $sql .= ") VALUES ("; - + $sql .= " '" . $this->db->idate($now) . "'"; $sql .= ", " . $conf->entity; $sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); @@ -147,25 +147,25 @@ class AccountingAccount { $sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); $sql .= ", " . $user->id; $sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); - + $sql .= ")"; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accountingaccount"); - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -174,7 +174,7 @@ class AccountingAccount { // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -188,7 +188,7 @@ class AccountingAccount { return $this->id; } } - + /** * Update record * @@ -197,9 +197,9 @@ class AccountingAccount { */ function update($user) { global $langs; - + $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " SET fk_pcg_version = " . ($this->fk_pcg_version ? "'" . $this->db->escape($this->fk_pcg_version) . "'" : "null"); $sql .= " , pcg_type = " . ($this->pcg_type ? "'" . $this->db->escape($this->pcg_type) . "'" : "null"); @@ -209,9 +209,9 @@ class AccountingAccount { $sql .= " , label = " . ($this->label ? "'" . $this->db->escape($this->label) . "'" : "null"); $sql .= " , fk_user_modif = " . $user->id; $sql .= " , active = '" . $this->active . "'"; - + $sql .= " WHERE rowid = " . $this->id; - + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -223,7 +223,7 @@ class AccountingAccount { return - 1; } } - + /** * Check usage of accounting code * @@ -232,16 +232,16 @@ class AccountingAccount { */ function checkUsage() { global $langs; - + $sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; $sql .= "UNION"; $sql .= "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql .= " WHERE fk_code_ventilation=" . $this->id . ")"; - + dol_syslog(get_class($this) . "::checkUsage sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $num = $this->db->num_rows($resql); if ($num > 0) { @@ -255,7 +255,7 @@ class AccountingAccount { return - 1; } } - + /** * Delete object in database * @@ -266,18 +266,18 @@ class AccountingAccount { function delete($user, $notrigger = 0) { global $conf, $langs; $error = 0; - + $result = $this->checkUsage(); - + if ($result > 0) { - + $this->db->begin(); - + if (! $error) { if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -286,11 +286,11 @@ class AccountingAccount { // // End call triggers } } - + if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accountingaccount"; $sql .= " WHERE rowid=" . $this->id; - + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (! $resql) { @@ -298,7 +298,7 @@ class AccountingAccount { $this->errors[] = "Error " . $this->db->lasterror(); } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -315,7 +315,7 @@ class AccountingAccount { return - 1; } } - + /** * Information on record * @@ -326,10 +326,10 @@ class AccountingAccount { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a'; $sql .= ' WHERE a.rowid = ' . $id; - + dol_syslog(get_class($this) . '::info sql=' . $sql); $result = $this->db->query($sql); - + if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); @@ -352,7 +352,7 @@ class AccountingAccount { dol_print_error($this->db); } } - + /** * Account desactivate * @@ -361,19 +361,19 @@ class AccountingAccount { */ function account_desactivate($id) { global $langs; - + $result = $this->checkUsage(); - + if ($result > 0) { $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= "SET active = '0'"; $sql .= " WHERE rowid = ".$this->db->escape($id); - + dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $this->db->commit(); return 1; @@ -386,7 +386,7 @@ class AccountingAccount { return - 1; } } - + /** * Account activate * @@ -395,13 +395,13 @@ class AccountingAccount { */ function account_activate($id) { global $langs; - + $this->db->begin(); - + $sql = "UPDATE " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= "SET active = '1'"; $sql .= " WHERE rowid = ".$this->db->escape($id); - + dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8b9666cc0a7..2788526de05 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2005 Rodolphe Quiedeville * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2014 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ class BookKeeping var $piece_num; var $linesexport = array (); var $linesmvt = array (); - + /** * Constructor * @@ -59,7 +59,7 @@ class BookKeeping { $this->db = $db; } - + /** * Load a line into memory from database * @@ -74,14 +74,14 @@ class BookKeeping $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE rowid = '" . $id . "'"; - + dol_syslog(get_class($this) . "fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + $this->id = $obj->rowid; - + $this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_type = $obj->doc_type; $this->doc_ref = $obj->doc_ref; @@ -103,10 +103,10 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Load an accounting document into memory from database * @@ -118,12 +118,12 @@ class BookKeeping $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE piece_num = '" . $piecenum . "'"; - + dol_syslog(get_class($this) . "fetch_per_mvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - + $this->piece_num = $obj->piece_num; $this->code_journal = $obj->code_journal; $this->doc_date = $this->db->jdate($obj->doc_date); @@ -134,10 +134,10 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** * Return next number movement * @@ -145,14 +145,14 @@ class BookKeeping */ function getNextNumMvt() { $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - + if ($result) { $obj = $this->db->fetch_object($result); - + return $obj->max; } else @@ -162,7 +162,7 @@ class BookKeeping return - 1; } } - + /** * Load all informations of accountancy document * @@ -177,17 +177,17 @@ class BookKeeping $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE piece_num = '" . $piecenum . "'"; - + dol_syslog(get_class($this) . "fetch_all_per_mvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { - + while ( $obj = $this->db->fetch_object($result) ) { - + $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -202,7 +202,7 @@ class BookKeeping $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesmvt[] = $line; } } else { @@ -210,40 +210,43 @@ class BookKeeping dol_syslog(get_class($this) . "::fetch_per_mvt " . $this->error, LOG_ERR); return - 1; } - + return 1; } - + /** - * \brief Insert line into bookkeeping - * \param user User who inserted operation + * Insert line into bookkeeping + * + * @param User $user User who inserted operation + * @return $result Result */ - function create() { + function create($user='') + { global $conf, $user, $langs; - + $this->piece_num = 0; - + // first check if line not yet in bookkeeping $sql = "SELECT count(*)"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); - + if ($resql) { $row = $this->db->fetch_array($resql); if ($row[0] == 0) { - + // Determine piece_num $sqlnum = "SELECT piece_num"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) @@ -256,7 +259,7 @@ class BookKeeping { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; - + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -268,11 +271,11 @@ class BookKeeping if (empty($this->piece_num)) { $this->piece_num = 1; } - + $now = dol_now(); if (empty($this->date_create)) $this->date_create = $now(); - + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping (doc_date, "; $sql .= "doc_type, doc_ref,fk_doc,fk_docdet,code_tiers,numero_compte,label_compte,"; $sql .= "debit,credit,montant,sens,fk_user_author,import_key,code_journal,piece_num)"; @@ -280,12 +283,12 @@ class BookKeeping $sql .= $this->fk_docdet . ",'" . $this->code_tiers . "','" . $this->numero_compte . "','" . $this->db->escape($this->label_compte) . "',"; $sql .= $this->debit . "," . $this->credit . "," . $this->montant . ",'" . $this->sens . "'," . $user->id . ", '"; $sql .= $this->date_create . "','" . $this->code_journal . "'," . $this->piece_num . ")"; - + dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); - + if ($id > 0) { $this->id = $id; $result = 0; @@ -305,27 +308,30 @@ class BookKeeping $result = - 5; dol_syslog("BookKeeping::Create Erreur $result SELECT Mysql"); } - + return $result; } - + /** - * \brief Delete bookkepping by importkey + * Delete bookkepping by importkey + * + * @param string $importkey Import key + * @return int Result */ function delete_by_importkey($importkey) { $this->db->begin(); - + // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping "; $sql .= " WHERE import_key = '" . $importkey . "'"; - + $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -339,7 +345,7 @@ class BookKeeping return 1; } } - + /** * Create object into database * @@ -351,7 +357,7 @@ class BookKeeping { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->doc_type)) $this->doc_type = trim($this->doc_type); @@ -383,10 +389,10 @@ class BookKeeping $this->code_journal = trim($this->code_journal); if (isset($this->piece_num)) $this->piece_num = trim($this->piece_num); - + // Check parameters // Put here code to add control on parameters values - + // Insert request $sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_bookkeeping("; $sql .= "doc_date,"; @@ -405,9 +411,9 @@ class BookKeeping $sql .= "import_key,"; $sql .= "code_journal,"; $sql .= "piece_num"; - + $sql .= ") VALUES ("; - + $sql .= " " . (! isset($this->doc_date) || dol_strlen($this->doc_date) == 0 ? 'NULL' : $this->db->idate($this->doc_date)) . ","; $sql .= " " . (! isset($this->doc_type) ? 'NULL' : "'" . $this->db->escape($this->doc_type) . "'") . ","; $sql .= " " . (! isset($this->doc_ref) ? 'NULL' : "'" . $this->db->escape($this->doc_ref) . "'") . ","; @@ -424,25 +430,25 @@ class BookKeeping $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ","; $sql .= " " . (! isset($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ","; $sql .= " " . (! isset($this->piece_num) ? 'NULL' : "'" . $this->piece_num . "'") . ""; - + $sql .= ")"; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::create_std sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "accounting_bookkeeping"); - + if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -451,7 +457,7 @@ class BookKeeping // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -465,7 +471,7 @@ class BookKeeping return $this->id; } } - + /** * Update object into database * @@ -477,7 +483,7 @@ class BookKeeping { global $conf, $langs; $error = 0; - + // Clean parameters if (isset($this->doc_type)) $this->doc_type = trim($this->doc_type); @@ -509,13 +515,13 @@ class BookKeeping $this->code_journal = trim($this->code_journal); if (isset($this->piece_num)) $this->piece_num = trim($this->piece_num); - + // Check parameters // Put here code to add a control on parameters values - + // Update request $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_bookkeeping SET"; - + $sql .= " doc_date=" . (dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ","; $sql .= " doc_type=" . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ","; $sql .= " doc_ref=" . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ","; @@ -532,23 +538,23 @@ class BookKeeping $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ","; $sql .= " code_journal=" . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ","; $sql .= " piece_num=" . (isset($this->piece_num) ? $this->piece_num : "null") . ""; - + $sql .= " WHERE rowid=" . $this->id; - + $this->db->begin(); - + dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error ++; $this->errors[] = "Error " . $this->db->lasterror(); } - + if (! $error) { if (! $notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. - + // // Call triggers // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; // $interface=new Interfaces($this->db); @@ -557,7 +563,7 @@ class BookKeeping // // End call triggers } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -571,7 +577,7 @@ class BookKeeping return 1; } } - + /** * Delete object in database * @@ -583,24 +589,24 @@ class BookKeeping { global $conf, $langs; $error = 0; - + $this->db->begin(); - + if (! $error) { if (! $notrigger) { // Call trigger $result=$this->call_trigger('ACCOUNTING_NUMPIECE_DELETE',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } } - + if (! $error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; $sql .= " WHERE rowid=" . $this->id; - + dol_syslog(get_class($this) . "::delete sql=" . $sql); $resql = $this->db->query($sql); if (! $resql) { @@ -608,7 +614,7 @@ class BookKeeping $this->errors[] = "Error " . $this->db->lasterror(); } } - + // Commit or rollback if ($error) { foreach ( $this->errors as $errmsg ) { @@ -624,9 +630,12 @@ class BookKeeping return 1; } } - + /** - * \brief Delete bookkepping by importkey + * Delete bookkepping by importkey + * + * @param string $model Model + * @return int Result */ function export_bookkeping($model = 'ebp') { @@ -635,20 +644,20 @@ class BookKeeping $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - + $resql = $this->db->query($sql); - + dol_syslog(get_class($this) . "::export_bookkeping sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->linesexport = array (); - + $num = $this->db->num_rows($resql); while ( $obj = $this->db->fetch_object($resql) ) { $line = new BookKeepingLine(); - + $line->id = $obj->rowid; - + $line->doc_date = $this->db->jdate($obj->doc_date); $line->doc_type = $obj->doc_type; $line->doc_ref = $obj->doc_ref; @@ -663,11 +672,11 @@ class BookKeeping $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; $line->piece_num = $obj->piece_num; - + $this->linesexport[] = $line; } $this->db->free($resql); - + return $num; } else @@ -679,6 +688,9 @@ class BookKeeping } } +/** + * Class BookKeepingLine + */ class BookKeepingLine { var $id; diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index b6d49e0c36a..7385219780b 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -19,10 +19,10 @@ /** * \file htdocs/accountancy/class/html.formventilation.class.php - * \ingroup Accounting Expert + * \ingroup Accounting Expert * \brief File of class with all html predefined components */ - + /** * Class to manage generation of HTML components for bank module */ @@ -30,7 +30,7 @@ class FormVentilation extends Form { var $db; var $error; - + /** * Constructor * @@ -48,33 +48,33 @@ class FormVentilation extends Form * @param string $selectedkey Value * @return string HTML edit field */ - function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey) + function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey='') { global $langs; - + $date_array = array (); - + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; - + $out = ''; - + return $out; } - + /** * Return list of accounts with label by chart of accounts * @@ -95,38 +95,38 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options - * + * * @return string String with HTML select */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array()) { global $conf, $user, $langs; - + $out = ''; - + $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " ORDER BY aa.account_number"; - + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); $out .= ''; if ($showempty) $out .= ''; @@ -184,7 +184,7 @@ class FormVentilation extends Form while ( $i < $num ) { $obj = $this->db->fetch_object($resql); $label = $obj->pcg_type; - + if (($selectid != '') && $selectid == $obj->pcg_type) { $out .= ''; } else { @@ -202,7 +202,7 @@ class FormVentilation extends Form $this->db->free($resql); return $out; } - + /** * Return list of accounts with label by sub_class of accounts * @@ -210,25 +210,25 @@ class FormVentilation extends Form * @param string $htmlname Name of field in html form * @param int $showempty Add an empty field * @param array $event Event options - * + * * @return string String with HTML select */ function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { global $conf, $user, $langs; - + $out = ''; - + $sql = "SELECT DISTINCT pcg_subtype "; $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount "; $sql .= " ORDER BY pcg_subtype"; - + dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - + $out .= ajax_combobox($htmlname, $event); - + $out .= ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print "
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '
'; @@ -127,13 +127,13 @@ if ($resql) { print '' . $obj->ref . '' . $obj->label . '' . $obj->description . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . '' . $obj->accountancy_code_sell . '' . $compta_prodsell . '
"; print ""; @@ -528,18 +528,18 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + if ($val["lib"] == '(SupplierInvoicePayment)') $reflabel = $langs->trans('SupplierInvoicePayment'); if ($val["lib"] == '(CustomerInvoicePayment)') $reflabel = $langs->trans('CustomerInvoicePayment'); - + // Bank foreach ( $tabbq[$key] as $k => $mt ) { if (1) { @@ -554,7 +554,7 @@ if ($action == 'export_csv') { print ""; } } - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { @@ -569,12 +569,12 @@ if ($action == 'export_csv') { print ""; } } - + $var = ! $var; } - + print "
" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/accountancy/journal/cashjournal.php b/htdocs/accountancy/journal/cashjournal.php index e7e065577c6..64b450497b9 100644 --- a/htdocs/accountancy/journal/cashjournal.php +++ b/htdocs/accountancy/journal/cashjournal.php @@ -38,7 +38,7 @@ if (! $res && file_exists("../../../main.inc.php")) $res = @include ("../../../main.inc.php"); if (! $res) die("Include of main fails"); - + // Class dol_include_once("/core/lib/report.lib.php"); dol_include_once("/core/lib/date.lib.php"); @@ -127,24 +127,24 @@ $paymentvatstatic = new TVA($db); dol_syslog("accountancy/journal/cashjournal.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { - + $num = $db->num_rows($result); // les variables $cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); $cptcli = (! empty($conf->global->COMPTA_ACCOUNT_CUSTOMER) ? $conf->global->COMPTA_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef")); $cpttva = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); $cptsociale = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) ? $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE : $langs->trans("CodeNotDef")); - + $tabpay = array (); $tabbq = array (); $tabtp = array (); $tabcompany = array (); $tabtype = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - + // controls $compta_bank = $obj->account_number; if ($obj->label == '(SupplierInvoicePayment)') @@ -153,9 +153,9 @@ if ($result) { $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); if ($obj->typeop == '(BankTransfert)') $compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH; - + // variable bookkeeping - + $tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["ref"] = $obj->label; $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid; @@ -165,11 +165,11 @@ if ($result) { $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); } $links = $object->get_url($obj->rowid); - + foreach ( $links as $key => $val ) { - + $tabtype[$obj->rowid] = $links[$key]['type']; - + if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); @@ -178,16 +178,16 @@ if ($result) { $paymentsupplierstatic->ref = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); } else if ($links[$key]['type'] == 'company') { - + $societestatic->id = $links[$key]['url_id']; $societestatic->nom = $links[$key]['label']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); $tabtp[$obj->rowid][$compta_soc] += $obj->amount; } else if ($links[$key]['type'] == 'sc') { - + $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; - + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') @@ -198,7 +198,7 @@ if ($result) { } $chargestatic->ref = $chargestatic->lib; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); - + $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; @@ -212,7 +212,7 @@ if ($result) { $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount; } } else if ($links[$key]['type'] == 'payment_vat') { - + $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); @@ -226,9 +226,9 @@ if ($result) { }*/ } $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; - + $i ++; } } else { @@ -254,14 +254,14 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; $bookkeeping->numero_compte = $k; $bookkeeping->label_compte = $compte->intitule; - $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt >= 0) ? $mt : 0; - $bookkeeping->credit = ($mt < 0 ? price - ($mt) : 0); + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); + $bookkeeping->credit = ($mt < 0 ? - $mt : 0); $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; - + if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -274,7 +274,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -287,7 +287,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } } - + $result = $bookkeeping->create(); if ($result < 0) { $error ++; @@ -296,7 +296,7 @@ if ($action == 'writeBookKeeping') { } // third party foreach ( $tabtp[$key] as $k => $mt ) { - + $bookkeeping = new BookKeeping($db); $bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_ref = $val["ref"]; @@ -304,17 +304,17 @@ if ($action == 'writeBookKeeping') { $bookkeeping->fk_doc = $key; $bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->montant = ($mt < 0 ? price - ($mt) : $mt); + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? price - ($mt) : 0); - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0 ? $mt : 0); $bookkeeping->code_journal = $conf->global->ACCOUNTING_CASH_JOURNAL; - + if ($tabtype[$key] == 'sc') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -329,7 +329,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -344,7 +344,7 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_SUPPLIER; } else if ($tabtype[$key] == 'company') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -359,11 +359,11 @@ if ($action == 'writeBookKeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } else { - + $bookkeeping->doc_ref = $k; $bookkeeping->numero_compte = $conf->global->COMPTA_ACCOUNT_CUSTOMER; } - + $result = $bookkeeping->create(); if ($result < 0) { $error ++; @@ -371,7 +371,7 @@ if ($action == 'writeBookKeeping') { } } } - + if (empty($error)) { setEventMessage($langs->trans('Success'), 'mesgs'); } @@ -379,19 +379,19 @@ if ($action == 'writeBookKeeping') { // export csv if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_SEPARATORCSV; - + header('Content-Type: text/csv'); header('Content-Disposition:attachment;filename=journal_caisse.csv'); - + if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert { foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Cash print $date . $sep; print $conf->global->ACCOUNTING_CASH_JOURNAL . $sep; - + foreach ( $tabbq[$key] as $k => $mt ) { print length_accountg(html_entity_decode($k)) . $sep; print $sep; @@ -401,7 +401,7 @@ if ($action == 'export_csv') { print utf8_decode($langs->trans("CashPayment")) . $sep; print $val["ref"] . $sep; print "\n"; - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($mt) { @@ -427,7 +427,7 @@ if ($action == 'export_csv') { $date = dol_print_date($db->jdate($val["date"]), 'day'); print '"' . $date . '"' . $sep; print '"' . $val["ref"] . '"' . $sep; - + // Cash foreach ( $tabbq[$key] as $k => $mt ) { print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; @@ -436,7 +436,7 @@ if ($action == 'export_csv') { print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; } print "\n"; - + // Third party foreach ( $tabtp[$key] as $k => $mt ) { if ($mt) { @@ -452,11 +452,11 @@ if ($action == 'export_csv') { } } } else { - + $form = new Form($db); - + llxHeader('', $langs->trans("CashJournal"), ''); - + $nom = $langs->trans("CashJournal"); $nomlink = ''; $periodlink = ''; @@ -465,11 +465,11 @@ if ($action == 'export_csv') { $description = $langs->trans("DescCashJournal") . '
'; $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); - + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -497,13 +497,13 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + // Cash foreach ( $tabbq[$key] as $k => $mt ) { if (1) { @@ -516,26 +516,26 @@ if ($action == 'export_csv') { print ""; } } - + // third party foreach ( $tabtp[$key] as $k => $mt ) { if ($k != 'type') { print ""; - + print ""; print ""; - + print ""; print '"; print '"; } } - + $var = ! $var; } - + print "
" . $langs->trans("Account") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . $val["soclib"] . "" . length_accounta($k) . "' . ($mt < 0 ? price(- $mt) : '') . "' . ($mt >= 0 ? price($mt) : '') . "
"; - + // End of page llxFooter(); } diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 781bc24aa09..5896ffc5416 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -204,9 +204,9 @@ else // Add vat rates examples specific to country $vat_rates=array(); - $sql.="SELECT taux as vat_rate"; + $sql="SELECT taux as vat_rate"; $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND taux != 0"; + $sql.=" WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0"; $sql.=" ORDER BY t.taux ASC"; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ac66f7fb048..a12b6dc7256 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011 Jean Heimburger @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU *General Public License as published by + * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 876e2966ccd..67a93eadc44 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -249,18 +249,23 @@ else if ($action == 'setmode' && $user->rights->facture->creer) { dol_print_error($db, $object->error); } -else if ($action == 'setinvoicedate' && $user->rights->facture->creer) { +else if ($action == 'setinvoicedate' && $user->rights->facture->creer) +{ $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; - $object->date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); + $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); + if (empty($date)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); + exit; + } + $object->date=$date; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) - $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) - $object->date_lim_reglement = $object->date; + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; $result = $object->update($user); - if ($result < 0) - dol_print_error($db, $object->error); + if ($result < 0) dol_print_error($db, $object->error); } else if ($action == 'setconditions' && $user->rights->facture->creer) { @@ -268,18 +273,14 @@ else if ($action == 'setconditions' && $user->rights->facture->creer) { $object->cond_reglement_code = 0; // To clean property $object->cond_reglement_id = 0; // To clean property $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - if ($result < 0) - dol_print_error($db, $object->error); + if ($result < 0) dol_print_error($db, $object->error); $old_date_lim_reglement = $object->date_lim_reglement; $new_date_lim_reglement = $object->calculate_date_lim_reglement(); - if ($new_date_lim_reglement > $old_date_lim_reglement) - $object->date_lim_reglement = $new_date_lim_reglement; - if ($object->date_lim_reglement < $object->date) - $object->date_lim_reglement = $object->date; + if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement = $new_date_lim_reglement; + if ($object->date_lim_reglement < $object->date) $object->date_lim_reglement = $object->date; $result = $object->update($user); - if ($result < 0) - dol_print_error($db, $object->error); + if ($result < 0) dol_print_error($db, $object->error); } else if ($action == 'setpaymentterm' && $user->rights->facture->creer) { @@ -940,7 +941,7 @@ else if ($action == 'add' && $user->rights->facture->creer) { // Don't add lines with qty 0 when coming from a shipment including all order lines if($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue; - + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); @@ -1159,12 +1160,12 @@ else if ($action == 'addline' && $user->rights->facture->creer) // We define price for product if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) { - $pu_ht = $prod->multiprices [$object->thirdparty->price_level]; - $pu_ttc = $prod->multiprices_ttc [$object->thirdparty->price_level]; - $price_min = $prod->multiprices_min [$object->thirdparty->price_level]; - $price_base_type = $prod->multiprices_base_type [$object->thirdparty->price_level]; - $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; + $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; + //$tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + //$tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index b6f2b02567a..14963b72288 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -508,7 +508,7 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function security_prepare_head() { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index a0c1e3f1b4b..007f8474721 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -360,7 +360,7 @@ function show_array_last_actions_done($max=5) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function agenda_prepare_head() { @@ -405,7 +405,7 @@ function agenda_prepare_head() * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function actions_prepare_head($object) { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 79ceb73d05a..f91ec3d188d 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -31,7 +31,7 @@ * * @param string $selected Preselecte value * @param string $htmlname HTML name of input field - * @param string $url Url for request: /chemin/fichier.php + * @param string $url Url for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list) * @param string $urloption More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value @@ -98,26 +98,30 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("input#search_'.$htmlname.'").autocomplete({ source: function( request, response ) { $.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){ - response($.map( data, function( item ) { - if (autoselect == 1 && data.length == 1) { - $("#search_'.$htmlname.'").val(item.value); - $("#'.$htmlname.'").val(item.key).trigger("change"); - } - var label = item.label.toString(); - var update = {}; - if (options.update) { - $.each(options.update, function(key, value) { - update[key] = item[value]; - }); - } - var textarea = {}; - if (options.update_textarea) { - $.each(options.update_textarea, function(key, value) { - textarea[key] = item[value]; - }); - } - return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled } - })); + if (data != null) + { + response($.map( data, function(item) { + if (autoselect == 1 && data.length == 1) { + $("#search_'.$htmlname.'").val(item.value); + $("#'.$htmlname.'").val(item.key).trigger("change"); + } + var label = item.label.toString(); + var update = {}; + if (options.update) { + $.each(options.update, function(key, value) { + update[key] = item[value]; + }); + } + var textarea = {}; + if (options.update_textarea) { + $.each(options.update_textarea, function(key, value) { + textarea[key] = item[value]; + }); + } + return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled } + })); + } + else console.error("Error: Ajax url '.$url.($urloption?'?'.$urloption:'').' has returned an empty page. Should be an empty json array."); }, "json"); }, dataType: "json", diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index c17c78bc8e1..349cb15063f 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -28,7 +28,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function bank_prepare_head($object) { diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index fb3a0210ef6..4d020526e44 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -27,7 +27,7 @@ * * @param Object $object Object related to tabs * @param string $type Type of category - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function categories_prepare_head($object,$type) { diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php index b729aae2589..2518f7b7883 100644 --- a/htdocs/core/lib/contact.lib.php +++ b/htdocs/core/lib/contact.lib.php @@ -26,7 +26,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function contact_prepare_head($object) { diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 1086d4dcd14..e51f7594ac9 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -26,7 +26,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function contract_prepare_head($object) { diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php index 1257d6a9bd1..2f12976e49f 100644 --- a/htdocs/core/lib/ecm.lib.php +++ b/htdocs/core/lib/ecm.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of different ecm main dashboard * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_dasboard_head($object) { @@ -64,7 +64,7 @@ function ecm_prepare_dasboard_head($object) * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_head($object) { @@ -84,7 +84,7 @@ function ecm_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_file_prepare_head($object) { @@ -104,7 +104,7 @@ function ecm_file_prepare_head($object) * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ecm_prepare_head_fm($object) { diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 6c06a1eccb2..613b12dadad 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function emailing_prepare_head($object) { diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index cb30a202513..7242a8e3bab 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -28,7 +28,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function fichinter_prepare_head($object) { diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php index 60b2c810294..1db099b24bf 100644 --- a/htdocs/core/lib/fiscalyear.lib.php +++ b/htdocs/core/lib/fiscalyear.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function fiscalyear_prepare_head($object) { diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 171eda67a90..58d553e36d5 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function facturefourn_prepare_head($object) { @@ -92,7 +92,7 @@ function facturefourn_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function ordersupplier_prepare_head($object) { diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 948bd74281c..43427acd59a 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function commande_prepare_head($object) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e0c6c9ee0e0..3c56cfcae3d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -269,7 +269,9 @@ function pdf_getPDFFontSize($outputlangs) */ function pdf_getHeightForLogo($logo, $url = false) { - $height=22; $maxwidth=130; + global $conf; + $height=(empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT)?22:$conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT); + $maxwidth=130; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $tmp=dol_getImageSize($logo, $url); if ($tmp['height']) diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php index c6305423a96..dde5981cf75 100644 --- a/htdocs/core/lib/prelevement.lib.php +++ b/htdocs/core/lib/prelevement.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function prelevement_prepare_head($object) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index a252b361dcf..d8f814e06c3 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -29,7 +29,7 @@ * * @param Object $object Object related to tabs * @param User $user Object user - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function product_prepare_head($object, $user) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 3a4a2dc6035..e44b0dd413c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function project_prepare_head($object) { @@ -113,7 +113,7 @@ function project_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function task_prepare_head($object) { @@ -170,7 +170,7 @@ function task_prepare_head($object) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function project_admin_prepare_head() { diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 3a5b25da295..bc0c7cae868 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of tabs * * @param object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function propal_prepare_head($object) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index d2f3bf563c6..d2ff595b734 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function shipping_prepare_head($object) { @@ -85,7 +85,7 @@ function shipping_prepare_head($object) * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function delivery_prepare_head($object) { diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php index 2ebbb529407..3305f76875d 100644 --- a/htdocs/core/lib/stock.lib.php +++ b/htdocs/core/lib/stock.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function stock_prepare_head($object) { diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 164d346ac1c..62e46b7b9f7 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -29,7 +29,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function tax_prepare_head($object) { diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php index 7d58e9e01b1..ae38a1bf706 100644 --- a/htdocs/core/lib/trip.lib.php +++ b/htdocs/core/lib/trip.lib.php @@ -25,7 +25,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function trip_prepare_head($object) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 97354bd08ab..276efe85f02 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -27,7 +27,7 @@ * Prepare array with list of tabs * * @param Object $object Object related to tabs - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function user_prepare_head($object) { @@ -178,7 +178,7 @@ function group_prepare_head($object) /** * Prepare array with list of tabs * - * @return array Array of tabs to shoc + * @return array Array of tabs to show */ function user_admin_prepare_head() { diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index ff38bc5f9cb..28260de97d8 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -26,8 +26,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; -/** \class mod_propale_marbre - * \brief Class to manage customer order numbering rules Marbre +/** + * Class to manage customer order numbering rules Marbre */ class mod_propale_marbre extends ModeleNumRefPropales { @@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales } else { - dol_syslog("mod_propale_marbre::getNextValue", LOG_DEBUG); + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); return -1; } @@ -134,7 +134,7 @@ class mod_propale_marbre extends ModeleNumRefPropales if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is else $num = sprintf("%04s",$max+1); - dol_syslog("mod_propale_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); + dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num); return $this->prefix.$yymm."-".$num; } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 5838000382c..503d8754684 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; /** - * \class mod_propale_saphir - * \brief Class of file that contains the numbering module rules Saphir + * Class of file that contains the numbering module rules Saphir */ class mod_propale_saphir extends ModeleNumRefPropales { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 49db958fa32..7e327eb896a 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -278,7 +278,7 @@ class Fichinter extends CommonObject $sql.= " f.datec,"; $sql.= " f.date_valid as datev,"; $sql.= " f.tms as datem,"; - $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams"; + $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; $sql.= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) $sql.= " WHERE f.ref='".$this->db->escape($ref)."'"; else $sql.= " WHERE f.rowid=".$rowid; @@ -304,6 +304,7 @@ class Fichinter extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; $this->extraparams = (array) json_decode($obj->extraparams, true); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 2e9a2a42616..b9c67d5a2b6 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -210,7 +210,8 @@ class CommandeFournisseur extends CommonOrder $sql.= " l.tva_tx, l.remise_percent, l.subprice,"; $sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,"; $sql.= " l.total_ht, l.total_tva, l.total_ttc,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,"; + $sql.= " l.date_start, l.date_end"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= " WHERE l.fk_commande = ".$this->id; @@ -258,6 +259,9 @@ class CommandeFournisseur extends CommonOrder $line->ref_fourn = $objp->ref_supplier; // TODO deprecated $line->ref_supplier = $objp->ref_supplier; // Reference supplier + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $this->lines[$i] = $line; $i++; @@ -1721,9 +1725,11 @@ class CommandeFournisseur extends CommonOrder * @param int $info_bits Miscellaneous informations * @param int $type Type of line (0=product, 1=service) * @param int $notrigger Disable triggers + * @param timestamp $date_start Date start of service + * @param timestamp $date_end Date end of service * @return int < 0 if error, > 0 if ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false) + function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='') { global $mysoc; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type"); @@ -1784,10 +1790,8 @@ class CommandeFournisseur extends CommonOrder $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; $sql.= ",qty='".price2num($qty)."'"; - /*if ($date_end) { $sql.= ",date_start='$date_end'"; } - else { $sql.=',date_start=null'; } - if ($date_end) { $sql.= ",date_end='$date_end'"; } - else { $sql.=',date_end=null'; }*/ + $sql.= ",date_start=".(! empty($date_start)?"'".$this->db->idate($date_start)."'":"null"); + $sql.= ",date_end=".(! empty($date_end)?"'".$this->db->idate($date_end)."'":"null"); $sql.= ",info_bits='".$info_bits."'"; $sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_tva='".price2num($total_tva)."'"; @@ -2008,7 +2012,7 @@ class CommandeFournisseur extends CommonOrder /** * Classe de gestion des lignes de commande */ -class CommandeFournisseurLigne +class CommandeFournisseurLigne extends CommonOrderLine { // From llx_commandedet var $qty; @@ -2029,6 +2033,8 @@ class CommandeFournisseurLigne var $total_ttc; var $info_bits; var $special_code; + var $date_start; + var $date_end; // From llx_product var $libelle; // Label produit @@ -2061,7 +2067,8 @@ class CommandeFournisseurLigne $sql.= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql.= ' cd.total_localtax1, cd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,'; + $sql.= ' cd.date_start, cd.date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; $sql.= ' WHERE cd.rowid = '.$rowid; @@ -2092,6 +2099,9 @@ class CommandeFournisseurLigne $this->product_libelle = $objp->product_libelle; $this->product_desc = $objp->product_desc; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->db->free($result); return 1; } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index a5d377c9e39..f4f69fbd269 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -80,6 +80,9 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +//Date prefix +$date_pf = ''; + // Load object if ($id > 0 || ! empty($ref)) { @@ -191,6 +194,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) // Set if we used free entry or predefined product $predef=''; $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -276,7 +281,12 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $productsupplier->fourn_ref, $remise_percent, 'HT', - $type + $pu_ttc, + $type, + '', + '', + $date_start, + $date_end ); } if ($idprod == -2 || $idprod == 0) @@ -314,14 +324,14 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { $price_base_type = 'HT'; $ht = price2num($_POST['price_ht']); - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type); + $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end); } else { $ttc = price2num($_POST['price_ttc']); $ht = $ttc / (1 + ($tauxtva / 100)); $price_base_type = 'HT'; - $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type); + $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end); } } @@ -393,6 +403,9 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer if (!$res) dol_print_error($db); } + $date_start=dol_mktime(GETPOST('date_start'.$date_pf.'hour'), GETPOST('date_start'.$date_pf.'min'), 0, GETPOST('date_start'.$date_pf.'month'), GETPOST('date_start'.$date_pf.'day'), GETPOST('date_start'.$date_pf.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$date_pf.'hour'), GETPOST('date_end'.$date_pf.'min'), 0, GETPOST('date_end'.$date_pf.'month'), GETPOST('date_end'.$date_pf.'day'), GETPOST('date_end'.$date_pf.'year')); + $localtax1_tx=get_localtax($_POST['tva_tx'],1,$mysoc,$object->thirdparty); $localtax2_tx=get_localtax($_POST['tva_tx'],2,$mysoc,$object->thirdparty); @@ -407,7 +420,10 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer $localtax2_tx, 'HT', 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type + isset($_POST["type"])?$_POST["type"]:$line->product_type, + false, + $date_start, + $date_end ); unset($_POST['qty']); unset($_POST['type']); @@ -417,6 +433,8 @@ else if ($action == 'update_line' && $user->rights->fournisseur->commande->creer unset($_POST['np_desc']); unset($_POST['pu']); unset($_POST['tva_tx']); + unset($_POST['date_start']); + unset($_POST['date_end']); unset($localtax1_tx); unset($localtax2_tx); if ($result >= 0) @@ -1745,6 +1763,12 @@ elseif (! empty($object->id)) $doleditor=new DolEditor('eldesc',$line->description,'',200,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor->Create(); + print '
'; + print $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + print $form->select_date($date_start,'date_start'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,''); + print ' '.$langs->trans('to').' '; + print $form->select_date($date_end,'date_end'.$date_pf,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,''); + print ''; print ''; print $form->load_tva('tva_tx',$line->tva_tx,$object->thirdparty,$mysoc); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index f69d5fa879f..91f6fc9529e 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -466,7 +466,7 @@ if (empty($reshook)) if ($result > 0) { - header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref)); + header('Location: '.DOL_URL_ROOT.'/product/liste.php?type='.$object->type.'&delprod='.urlencode($object->ref)); exit; } else diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index 0b11ec3642b..2bf42cb4bba 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2012 Florian Henry + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -85,7 +86,7 @@ if (! empty($tag) && ($unsuscrib=='1')) $resql=$db->query($sql); //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT sc.rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index 03d6091f6c0..96ac9f0154b 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/product/ajax/products.php + * \file htdocs/product/ajax/company.php * \brief File to return Ajax response on product list request */ diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 68c12c64bef..1d81029a1e4 100644 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -586,6 +586,10 @@ div.login { height: 16px; } +#securitycode { + min-width: 60px; +} + img.login, img.printer, img.entity { margin:2px 0px 0px 0px; text-decoration:none; diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index b3677d0e2ca..c5d36b6d699 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -552,6 +552,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 566bc206742..867f25e1d0d 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -578,6 +578,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index d38a460d5e8..1c6e13944ca 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -651,6 +651,9 @@ form#login { background-image: -ms-linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); background-image: linear-gradient(top, rgba(240,240,240,.3) 0%, rgba(192,192,192,.3) 100%); } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cf642220116..1a0423d2b16 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -861,6 +861,9 @@ div#login_left, div#login_right { table.login_table tr td table.none tr td { padding: 2px; } +#securitycode { + min-width: 60px; +} #img_securitycode { border: 1px solid #DDDDDD; } diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index 7fb4a7c56e0..2556457f38e 100644 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -35,7 +35,7 @@ $langs->load("accountancy"); // Security check if (!$user->admin) accessforbidden(); - + // Date range $year = GETPOST("year"); if (empty($year)) { @@ -105,9 +105,8 @@ $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . $description = $langs->trans("DescThirdPartyReport"); $builddate = time(); -report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( - 'action' => '' -)); +$moreparam=array('action' => ''); +report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam); print ''; @@ -157,16 +156,16 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - + // export csv if (GETPOST('action') == 'export_csv') { - + header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=export_csv.csv'); - + $obj = $db->fetch_object($resql); $var = ! $var; - + print '"' . $obj->compta . '",'; print '"' . $obj->address . '",'; print '"' . $obj->zip . '",'; @@ -177,15 +176,15 @@ if ($resql) { print "\n"; $i ++; } - + /* * View */ - + $thirdpartystatic = new Societe($db); - + print '

'; - + print ''; print "
\n"; print ''; @@ -201,13 +200,13 @@ if ($resql) { print '' . $langs->trans("Contact") . ''; print '' . $langs->trans("Phone") . ''; print '' . $langs->trans("Fax") . ''; - + $var = True; - + while ( $obj = $db->fetch_object($resql) ) { - + $var = ! $var; - + print ""; print ''; $thirdpartystatic->id = $obj->rowid; @@ -227,10 +226,10 @@ if ($resql) { print '' . $obj->phone . ''; print '' . $obj->fax . ''; print "\n"; - + $i ++; } - + print ""; $db->free($resql); } else {