From c44207f7d36279cce6483cd9fe8b86930c8a21d0 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 14 Oct 2017 12:39:39 +0200 Subject: [PATCH 1/7] template file not only odt/ods --- htdocs/core/lib/functions2.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3d2e2bb359b..044a885aded 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1606,7 +1606,8 @@ function getListOfModels($db,$type,$maxfilenamelength=0) if (! $tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0); + // all type of template is allowed + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); } } From 75835dd7fd99f322b703b77d05e9cd2bb11343d3 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sun, 15 Oct 2017 13:33:48 +0200 Subject: [PATCH 2/7] Add Autofill button for amount to pay in charge payment page --- htdocs/compta/paiement_charge.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 398f70ad36a..95426b824a1 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -169,6 +169,20 @@ if ($action == 'create') $charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype; $total = $charge->amount; + if (! empty($conf->use_javascript_ajax)) + { + print "\n".''."\n"; + } print load_fiche_titre($langs->trans("DoPayment")); print "
\n"; @@ -294,7 +308,12 @@ if ($action == 'create') if ($sumpaid < $objp->amount) { $namef = "amount_".$objp->id; - print ''; + $nameRemain = "remain_".$objp->id; + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); + $remaintopay=$objp->amount - $sumpaid; + print ''; + print ''; } else { From afdc176f472aa67e667ca481f694c0a5006393ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 08:52:00 +0200 Subject: [PATCH 3/7] Fix scrutinizer --- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/api/class/api_documents.class.php | 12 ++++++----- htdocs/blockedlog/class/blockedlog.class.php | 20 +++++++++---------- .../core/class/emailsenderprofile.class.php | 2 ++ htdocs/core/lib/files.lib.php | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index bdb43dd41d3..397be6ee8da 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -216,7 +216,7 @@ class Subscription extends CommonObject $result=$member->fetch($this->fk_adherent); $result=$member->update_end_date($user); - if (is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) { $result=$accountline->delete($user); // Return false if refused because line is conciliated if ($result > 0) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 397910a6e2f..b47584eea99 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -130,18 +130,20 @@ class Documents extends DolibarrApi } /** - * Return the list of documents of an element + * Return the list of documents of a dedicated element (from its ID or Ref) * - * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) - * @param int $id ID of element + * @param string $modulepart Name of module or area concerned ('facture', 'project', 'member', ...) + * @param int $id ID of element * @param string $ref Ref of element - * @return array Array of documents with path + * @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size') + * @param string $sortorder Sort order ('asc' or 'desc') + * @return array Array of documents with path * * @throws RestException * * @url GET list */ - function getDocumentsListByElement($modulepart, $id=0, $ref='') + function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') { global $conf; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8a1508b7a04..4bce16fb796 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -21,13 +21,15 @@ class BlockedLog { - /** * Id of the log * @var int */ public $id; + public $error = ''; + public $errors = array(); + /** * Unique fingerprint of the log * @var string @@ -78,7 +80,7 @@ class BlockedLog public $object_data = null; - public $error = 0; + /** * Constructor @@ -126,7 +128,7 @@ class BlockedLog /** * try to retrieve user author - */ + */ public function getUser() { global $langs, $cachedUser; @@ -188,8 +190,6 @@ class BlockedLog $this->object_data->amounts = $object->amounts; } - - } /** @@ -231,7 +231,7 @@ class BlockedLog $this->action = $obj->action; $this->element = $obj->element; - $this->fk_object = trim($obj->fk_object); + $this->fk_object = $obj->fk_object; $this->date_object = $this->db->jdate($obj->date_object); $this->ref_object = $obj->ref_object; @@ -432,10 +432,10 @@ class BlockedLog /** * return log object for a element. * - * @param string $element element to search - * @param int $fk_object id of object to search - * @param int $limit max number of element, 0 for all - * @param string $order sort of query + * @param string $element element to search + * @param int $fk_object id of object to search + * @param int $limit max number of element, 0 for all + * @param string $order sort of query * @return array array of object log */ public function getLog($element, $fk_object, $limit = 0, $order = -1) { diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 66e37744cc7..f779e949dc3 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -273,6 +273,8 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; + $label=$this->label; + $url=''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 44a404c6c67..2f59c7e388c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -47,7 +47,7 @@ function dol_basename($pathfile) * @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function, * but must not contains the start and end '/'. Filter is checked into basename only. * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath. - * @param string $sortcriteria Sort criteria ("","fullname","relativename","name","date","size") + * @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size') * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only * @param int $nohook Disable all hooks From 87814af7b6170f1501dba0a492a1bc8568a01ccf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 09:29:10 +0200 Subject: [PATCH 4/7] Move function colorIsLight into functions.lib.php Fix scrutinizer bugs. --- .../accountancy/class/bookkeeping.class.php | 21 +++++--- htdocs/adherents/class/adherent.class.php | 4 +- .../adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/type.php | 4 +- htdocs/admin/mails_templates.php | 6 +-- htdocs/api/class/api_access.class.php | 4 +- htdocs/api/class/api_documents.class.php | 4 +- htdocs/cashdesk/class/Facturation.class.php | 53 ++++++++++--------- htdocs/categories/class/categorie.class.php | 17 ++---- htdocs/core/db/DoliDB.class.php | 8 +-- htdocs/core/lib/functions.lib.php | 34 ++++++++++++ htdocs/core/lib/functions2.lib.php | 34 ------------ 12 files changed, 99 insertions(+), 92 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 52f7a473bed..2d828298b51 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1079,22 +1079,26 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return number <0 if KO, >0 if OK */ - public function updateByMvt($piece_num='', $field='', $value='', $mode='') { + public function updateByMvt($piece_num='', $field='', $value='', $mode='') + { + $error=0; + $this->db->begin(); + $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab"; $sql .= ' SET ab.' . $field . '=' . (is_numeric($value)?$value:"'".$value."'"); $sql .= ' WHERE ab.piece_num=' . $piece_num ; $resql = $this->db->query($sql); if (! $resql) { - $error ++; + $error++; $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); } if ($error) { $this->db->rollback(); - return - 1 * $error; + return -1 * $error; } else { $this->db->commit(); @@ -1521,11 +1525,16 @@ class BookKeeping extends CommonObject * @param string $piece_num Piece num * @return void */ - public function transformTransaction($direction=0,$piece_num='') { + public function transformTransaction($direction=0,$piece_num='') + { + $error = 0; + $this->db->begin(); - if ($direction==0) { + + if ($direction==0) + { $next_piecenum=$this->getNextNumMvt(); - if ($result < 0) { + if ($next_piecenum < 0) { $error++; } $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,'; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c197d1a2362..33be4abb8e6 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1563,7 +1563,7 @@ class Adherent extends CommonObject * @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) * @param int $maxlen length max label * @param string $option Page for link ('card', 'category', 'subscription', ...) - * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref + * @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref * @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 Chaine avec URL @@ -1574,6 +1574,8 @@ class Adherent extends CommonObject if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; + $notooltip=0; + $result=''; $label=''; $link=''; $linkstart=''; $linkend=''; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 99c343a1ff0..f65e363cef9 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -167,7 +167,7 @@ class AdherentType extends CommonObject $sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "note = '".$this->db->escape($this->note)."',"; - $sql.= "vote = '".$this->db->escape($this->vote)."',"; + $sql.= "vote = ".(integer) $this->db->escape($this->vote).","; $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; $sql.= " WHERE rowid =".$this->id; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c9edce35f60..7eaefa6fc33 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = (boolean) trim($vote); + $object->vote = trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 111084388ce..4e25e93084b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1019,9 +1019,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } print ''; } - elseif ($context == 'add' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'edit' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; - elseif ($context == 'hide' & in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'add' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'edit' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; + elseif ($context == 'hide' && in_array($fieldlist[$field], array('topic', 'joinfiles', 'content', 'content_lines'))) continue; else { $size=''; $class=''; $classtd=''; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index b2dcfefa49f..5848620f735 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -83,10 +83,10 @@ class DolibarrApiAccess implements iAuthenticate // api key can be provided in url with parameter api_key=xxx or ni header with header DOLAPIKEY:xxx $api_key = ''; - if (isset($_GET['api_key'])) + if (isset($_GET['api_key'])) // For backward compatibility { // TODO Add option to disable use of api key on url. Return errors if used. - $api_key = $_GET['api_key']; // For backward compatibility + $api_key = $_GET['api_key']; } if (isset($_GET['DOLAPIKEY'])) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index b47584eea99..92b48dfd0c6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -256,9 +256,11 @@ class Documents extends DolibarrApi // Define $uploadir $object = null; - $entity = $user->entity; + $entity = DolibarrApiAccess::$user->entity; if ($ref) { + $tmpreldir=''; + if ($modulepart == 'facture' || $modulepart == 'invoice') { $modulepart='facture'; diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index b55524a874a..8bfd1d3082c 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -117,7 +117,7 @@ class Facturation } // Define part of HT, VAT, TTC - $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $use_npr, $product->type, $mysoc, $localtaxarray); + $resultarray=calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray); // Calcul du total ht sans remise $total_ht = $resultarray[0]; @@ -207,6 +207,9 @@ class Facturation $total_ht=0; $total_ttc=0; + $total_vat = 0; + $total_localtax1 = 0; + $total_localtax2 = 0; $tab=array(); $tab = $_SESSION['poscart']; @@ -309,7 +312,7 @@ class Facturation public function ref($aRef=null) { - if ( !$aRef ) + if (is_null($aRef)) { return $this->ref; } @@ -330,9 +333,9 @@ class Facturation * @param int $aQte Qty * @return int Qty */ - public function qte( $aQte=null ) + public function qte($aQte=null) { - if ( !$aQte ) + if (is_null($aQte)) { return $this->qte; } @@ -357,7 +360,7 @@ class Facturation public function stock($aStock=null) { - if ( !$aStock ) + if (is_null($aStock)) { return $this->stock; } @@ -381,7 +384,7 @@ class Facturation public function remisePercent($aRemisePercent=null) { - if ( !$aRemisePercent ) + if (is_null($aRemisePercent)) { return $this->remise_percent; } @@ -405,7 +408,7 @@ class Facturation public function montantRemise($aMontantRemise=null) { - if ( !$aMontantRemise ) { + if (is_null($aMontantRemise)) { return $this->montant_remise; @@ -427,10 +430,10 @@ class Facturation * @param int $aPrix Price * @return string Stock */ - public function prix ( $aPrix=null ) + public function prix($aPrix=null) { - if ( !$aPrix ) { + if (is_null($aPrix)) { return $this->prix; @@ -454,7 +457,7 @@ class Facturation */ public function tva($aTva=null) { - if ( !$aTva ) { + if (is_null($aTva)) { return $this->tva; @@ -478,7 +481,7 @@ class Facturation */ public function numInvoice($aNumFacture=null) { - if ( !$aNumFacture ) { + if (is_null($aNumFacture)) { return $this->num_facture; @@ -499,10 +502,10 @@ class Facturation * @param int $aModeReglement Payment mode * @return int Payment mode */ - public function getSetPaymentMode( $aModeReglement=null ) + public function getSetPaymentMode($aModeReglement=null) { - if ( !$aModeReglement ) { + if (is_null($aModeReglement)) { return $this->mode_reglement; @@ -524,10 +527,10 @@ class Facturation * @param int $aMontantEncaisse Amount * @return int Amount */ - public function montantEncaisse( $aMontantEncaisse=null ) + public function montantEncaisse($aMontantEncaisse=null) { - if ( !$aMontantEncaisse ) { + if (is_null($aMontantEncaisse)) { return $this->montant_encaisse; @@ -549,10 +552,10 @@ class Facturation * @param int $aMontantRendu Amount * @return int Amount */ - public function montantRendu( $aMontantRendu=null ) + public function montantRendu($aMontantRendu=null) { - if ( !$aMontantRendu ) { + if (is_null($aMontantRendu)) { return $this->montant_rendu; } else if ( $aMontantRendu == 'RESET' ) { @@ -573,9 +576,9 @@ class Facturation * @param date $aPaiementLe Date * @return date Date */ - public function paiementLe( $aPaiementLe=null ) + public function paiementLe($aPaiementLe=null) { - if ( !$aPaiementLe ) { + if (is_null($aPaiementLe)) { return $this->paiement_le; @@ -596,9 +599,9 @@ class Facturation * @param int $aTotalHt Total amount * @return int Total amount */ - public function prixTotalHt( $aTotalHt=null ) + public function prixTotalHt($aTotalHt=null) { - if ( !$aTotalHt ) { + if (is_null($aTotalHt)) { return $this->prix_total_ht; @@ -619,9 +622,9 @@ class Facturation * @param int $aMontantTva Amount vat * @return int Amount vat */ - public function montantTva( $aMontantTva=null ) + public function montantTva($aMontantTva=null) { - if ( !$aMontantTva ) { + if (is_null($aMontantTva)) { return $this->montant_tva; @@ -643,9 +646,9 @@ class Facturation * @param int $aTotalTtc Amount ttc * @return int Amount ttc */ - public function prixTotalTtc( $aTotalTtc=null ) + public function prixTotalTtc($aTotalTtc=null) { - if ( !$aTotalTtc ) + if (is_null($aTotalTtc)) { return $this->prix_total_ttc; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6242691d1f1..7a7a6f06a1f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -163,7 +163,7 @@ class Categorie extends CommonObject */ public $socid; /** - * @var int Category type + * @var string Category type * * @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_SUPPLIER @@ -1327,6 +1327,7 @@ class Categorie extends CommonObject { $w = array(); $i = 0; + $forced_color=''; foreach ($way as $cat) { $i++; @@ -1340,12 +1341,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($cat->color) { - $hex=$cat->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($cat->color)) $forced_color='categtextblack'; } } } @@ -1602,12 +1598,7 @@ class Categorie extends CommonObject $forced_color='categtextwhite'; if ($this->color) { - $hex=$this->color; - $r = hexdec($hex[0].$hex[1]); - $g = hexdec($hex[2].$hex[3]); - $b = hexdec($hex[4].$hex[5]); - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + if (colorIsLight($this->color)) $forced_color='categtextblack'; } $link = ''; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 9fc1739334c..99b799d5d6e 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -59,7 +59,7 @@ abstract class DoliDB implements Database public $lastqueryerror; /** @var string Last error message */ public $lasterror; - /** @var int Last error number */ + /** @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $lasterrno; /** @var bool Status */ @@ -238,16 +238,16 @@ abstract class DoliDB implements Database else $return.=', '; $return.=preg_replace('/[^0-9a-z_\.]/i','',$val); - + $tmpsortorder = trim($orders[$i]); - + // Only ASC and DESC values are valid SQL if (strtoupper($tmpsortorder) === 'ASC') { $return .= ' ASC'; } elseif (strtoupper($tmpsortorder) === 'DESC') { $return .= ' DESC'; } - + $i++; } return $return; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f56cd2f523d..2626e917460 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6791,3 +6791,37 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield=' return ''; } } + +/** + * Return true if the color is light + * + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light + */ +function colorIsLight($stringcolor) +{ + $res = -1; + if (!empty($stringcolor)) + { + $res = 0; + $tmp=explode(',', $stringcolor); + if (count($tmp) > 1) // This is a comma RGB ('255','255','255') + { + $r = $tmp[0]; + $g = $tmp[1]; + $b = $tmp[2]; + } + else + { + $hexr=$stringcolor[0].$stringcolor[1]; + $hexg=$stringcolor[2].$stringcolor[3]; + $hexb=$stringcolor[4].$stringcolor[5]; + $r = hexdec($hexr); + $g = hexdec($hexg); + $b = hexdec($hexb); + } + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $res = 1; + } + return $res; +} diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 3d2e2bb359b..98d113525c1 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2153,40 +2153,6 @@ function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); } -/** - * Return true if the color is light - * - * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') - * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light - */ -function colorIsLight($stringcolor) -{ - $res = -1; - if (!empty($stringcolor)) - { - $res = 0; - $tmp=explode(',', $stringcolor); - if (count($tmp) > 1) // This is a comma RGB ('255','255','255') - { - $r = $tmp[0]; - $g = $tmp[1]; - $b = $tmp[2]; - } - else - { - $hexr=$stringcolor[0].$stringcolor[1]; - $hexg=$stringcolor[2].$stringcolor[3]; - $hexb=$stringcolor[4].$stringcolor[5]; - $r = hexdec($hexr); - $g = hexdec($hexg); - $b = hexdec($hexb); - } - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm - if ($bright > 0.6) $res = 1; - } - return $res; -} - /** * Applies the Cartesian product algorithm to an array * Source: http://stackoverflow.com/a/15973172 From 82348cc1e9edb703e0d0be293f9f489c8fbb31e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Oct 2017 10:17:57 +0200 Subject: [PATCH 5/7] NEW Can filter on date on the page showing existing bindings --- htdocs/accountancy/customer/lines.php | 31 +++++++++++++++++++- htdocs/accountancy/customer/list.php | 1 + htdocs/accountancy/expensereport/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/expensereport/list.php | 1 + htdocs/accountancy/supplier/lines.php | 33 +++++++++++++++++++++- htdocs/accountancy/supplier/list.php | 1 + 6 files changed, 97 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0e3e71c1527..13602160c48 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("bills"); @@ -51,6 +53,9 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); @@ -95,6 +100,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; $search_country = ''; $search_tvaintra = ''; } @@ -131,6 +139,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { */ $form = new Form($db); +$formother = new FormOther($db); llxHeader('', $langs->trans("CustomersVentilation") . ' - ' . $langs->trans("Dispatched")); @@ -197,6 +206,19 @@ if (strlen(trim($search_account))) { if (strlen(trim($search_vat))) { $sql .= natural_search("fd.tva_tx", $search_vat); } +if ($search_month > 0) +{ + if ($search_year > 0 && empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; + else if ($search_year > 0 && ! empty($search_day)) + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'"; + else + $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'"; +} +else if ($search_year > 0) +{ + $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; +} if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } @@ -237,6 +259,9 @@ if ($result) { $param .= "&search_account=" . $search_account; if ($search_vat) $param .= "&search_vat=" . $search_vat; + if ($search_day) $param.='&search_day='.urlencode($search_day); + if ($search_month) $param.='&search_month='.urlencode($search_month); + if ($search_year) $param.='&search_year='.urlencode($search_year); if ($search_country) $param .= "&search_country=" . $search_country; if ($search_tvaintra) @@ -267,7 +292,11 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year,'search_year',1, 20, 5); + print ''; print ''; //print ''; print ''; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 51f62ecabf6..2d26a2d06d8 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -115,6 +115,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; $search_month = ''; $search_year = ''; } diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 156d80f09e4..750a5bc9f25 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; // Langs $langs->load("compta"); @@ -50,6 +52,9 @@ $search_desc = GETPOST('search_desc', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha'); +$search_day=GETPOST("search_day","int"); +$search_month=GETPOST("search_month","int"); +$search_year=GETPOST("search_year","int"); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); @@ -90,6 +95,9 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_amount = ''; $search_account = ''; $search_vat = ''; + $search_day = ''; + $search_month = ''; + $search_year = ''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -123,6 +131,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { * View */ +$form = new Form($db); +$formother = new FormOther($db); + llxHeader('', $langs->trans("ExpenseReportsVentilation") . ' - ' . $langs->trans("Dispatched")); print '