From b0e9f31474a81b530974ee2fb64bee730dddf186 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 12:43:25 +0100 Subject: [PATCH 1/7] Fix responsive --- htdocs/contact/card.php | 16 ++++++++-------- htdocs/theme/eldy/style.css.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index e6429fdc6d7..37bd3078c7d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -530,9 +530,9 @@ else // Name print ''; - print 'lastname).'" autofocus="autofocus">'; + print 'lastname).'" autofocus="autofocus">'; print ''; - print 'firstname).'">'; + print 'firstname).'">'; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -567,7 +567,7 @@ else // Address if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party print ''; - print ''; + print ''; if ($conf->use_javascript_ajax && $socid > 0) { @@ -612,20 +612,20 @@ else // Phone / Fax if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone; // Predefined with third party print ''; - print 'phone_pro).'">'; + print 'phone_pro).'">'; print ''; - print 'phone_perso).'">'; + print 'phone_perso).'">'; if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax; // Predefined with third party print ''; - print 'phone_mobile).'">'; + print 'phone_mobile).'">'; print ''; - print 'fax).'">'; + print 'fax).'">'; // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''; - print 'email).'">'; + print 'email).'">'; if (! empty($conf->mailing->enabled)) { print ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3cce27c4a2a..3fabbf347c0 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -642,7 +642,7 @@ div.fiche>form>div.div-table-responsive { .clearboth { clear:both; } .hideobject { display: none; } .minwidth50 { min-width: 50px; } -/* rule to reduce top menu - 3rd reduction */ +/* rule for not too small screen only */ @media only screen and (min-width: px) { .minwidth100 { min-width: 100px; } @@ -731,7 +731,7 @@ div.fiche>form>div.div-table-responsive { .hideonsmartphone { display: none; } .noenlargeonsmartphone { width : 50px !important; display: inline !important; } - .maxwidthonsmartphone { max-width: 100px; } + .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } .maxwidth50onsmartphone { max-width: 40px; } .maxwidth75onsmartphone { max-width: 50px; } .maxwidth100onsmartphone { max-width: 70px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4ab240af4d6..236e87abc84 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -619,7 +619,7 @@ div.fiche>form>div.div-table-responsive { .clearboth { clear:both; } .hideobject { display: none; } .minwidth50 { min-width: 50px; } -/* rule to reduce top menu - 3rd reduction */ +/* rule for not too small screen only */ @media only screen and (min-width: px) { .minwidth100 { min-width: 100px; } @@ -709,7 +709,7 @@ div.fiche>form>div.div-table-responsive { .hideonsmartphone { display: none; } .noenlargeonsmartphone { width : 50px !important; display: inline !important; } - .maxwidthonsmartphone { max-width: 100px; } + .maxwidthonsmartphone, #search_newcompany.ui-autocomplete-input { max-width: 100px; } .maxwidth50onsmartphone { max-width: 40px; } .maxwidth75onsmartphone { max-width: 50px; } .maxwidth100onsmartphone { max-width: 70px; } From 66819a34fa18716babceb153aa0497e51ad79d54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 13:19:07 +0100 Subject: [PATCH 2/7] Fix several bugs --- htdocs/compta/prelevement/bons.php | 90 ++++++++++++++++++++++-------- htdocs/compta/prelevement/list.php | 66 ++++++++++++++-------- htdocs/compta/resultat/index.php | 6 +- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/list.php | 5 +- htdocs/langs/en_US/compta.lang | 2 +- 6 files changed, 118 insertions(+), 53 deletions(-) diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 695afb7562f..8f90183f0f7 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -37,33 +37,57 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -// Get supervariables +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -$sortorder = ((GETPOST('sortorder','alpha')=="")) ? "DESC" : GETPOST('sortorder','alpha'); -$sortfield = ((GETPOST('sortfield','alpha')=="")) ? "p.datec" : GETPOST('sortfield','alpha'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="p.datec"; + +// Get supervariables $statut = GETPOST('statut','int'); -$search_line = GETPOST('search_ligne','int'); +$search_ref = GETPOST('search_ref','alpha'); + + +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers +{ + $search_ref=""; +} + + +/* + * View + */ llxHeader('',$langs->trans("WithdrawalsReceipts")); $bon=new BonPrelevement($db,""); -if ($page == -1) { $page = 0 ; } -$offset = $conf->liste_limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; - - -/* - * Mode List - * - */ $sql = "SELECT p.rowid, p.ref, p.amount, p.statut"; $sql.= ", p.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " WHERE p.entity = ".$conf->entity; -$sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit+1, $offset); +if ($search_ref) $sql.=natural_search("p.ref", $search_ref); + +$sql.= $db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit + 1,$offset); $result = $db->query($sql); if ($result) @@ -73,9 +97,22 @@ if ($result) $urladd= "&statut=".$statut; - print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); + // Lines of title fields + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); - print ''; + $moreforfilter=''; + + print '
'; + print '
'."\n"; print ''; print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"'); @@ -84,17 +121,18 @@ if ($result) print "\n"; print ''; - print ''; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; print ''; $var=True; - while ($i < min($num,$conf->liste_limit)) - { + while ($i < min($num,$limit)) + { $obj = $db->fetch_object($result); $var=!$var; @@ -113,6 +151,10 @@ if ($result) $i++; } print "
 '; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print '
"; + print ''; + + print ''; + $db->free($result); } else diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 9e33bac4046..7a7eeb7610a 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -23,6 +23,7 @@ * \ingroup prelevement * \brief Page liste des prelevements */ + require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php'; @@ -38,10 +39,18 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -// Get supervariables + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); -$sortorder = ((GETPOST('sortorder','alpha')=="")) ? "DESC" : GETPOST('sortorder','alpha'); -$sortfield = ((GETPOST('sortfield','alpha')=="")) ? "p.datec" : GETPOST('sortfield','alpha'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="p.datec"; + $search_line = GETPOST('search_line','alpha'); $search_bon = GETPOST('search_bon','alpha'); $search_code = GETPOST('search_code','alpha'); @@ -51,9 +60,12 @@ $statut = GETPOST('statut','int'); $bon=new BonPrelevement($db,""); $ligne=new LignePrelevement($db,$user); -$offset = $conf->liste_limit * $page ; -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers { $search_line=""; $search_bon=""; @@ -62,10 +74,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $statut=""; } + /* * View */ +$form=new Form($db); + llxHeader('',$langs->trans("WithdrawalsLines")); $sql = "SELECT p.rowid, p.ref, p.statut, p.datec"; @@ -83,24 +98,22 @@ $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; if ($socid) $sql.= " AND s.rowid = ".$socid; -if ($search_line) +if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'"; +if ($search_bon) $sql.= natural_search("p.ref", $search_bon); +if ($search_code) $sql.= natural_search("s.code_client", $search_code); +if ($search_company) natural_search("s.nom", $search_company); + +$sql.= $db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $sql.= " AND pl.rowid = '".$db->escape($search_line)."'"; + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } -if ($search_bon) -{ - $sql.= " AND p.ref LIKE '%".$db->escape($search_bon)."%'"; -} -if ($search_code) -{ - $sql.= " AND s.code_client LIKE '%".$db->escape($search_code)."%'"; -} -if ($search_company) -{ - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; -} -$sql.=$db->order($sortfield,$sortorder); -$sql.=$db->plimit($conf->liste_limit+1, $offset); + +$sql.= $db->plimit($limit + 1,$offset); $result = $db->query($sql); if ($result) @@ -111,11 +124,15 @@ if ($result) $urladd = "&statut=".$statut; $urladd .= "&search_bon=".$search_bon; - print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); print"\n\n"; print '
'; - print ''; + + $moreforfilter=''; + + print '
'; + print '
'."\n"; print ''; print_liste_field_titre($langs->trans("Line"),$_SERVER["PHP_SELF"]); @@ -144,7 +161,7 @@ if ($result) $var=True; - while ($i < min($num,$conf->liste_limit)) + while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); @@ -185,6 +202,7 @@ if ($result) $i++; } print "
"; + print ''; print '
'; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 74b80ec0e82..5b2c6b70a13 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -641,7 +641,9 @@ if (! empty($conf->don->enabled)) $totentrees=array(); $totsorties=array(); -print ''; +print '
'; +print '
'."\n"; + print ''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) @@ -735,7 +737,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) print "\n"; print "
 
"; - +print ''; llxFooter(); $db->close(); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 827fd5c5e4a..4ed3ecb7cef 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -967,7 +967,7 @@ if ($action == 'create') // Description (must be a textarea and not html must be allowed (used in list view) print ''.$langs->trans("Description").''; print ''; - print ''; + print ''; print ''; // Project diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 9d01643825a..563c57f5ad7 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -251,7 +251,8 @@ if ($result) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print ''; + print '
'; + print '
'."\n"; print ''; if (! empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("ThirdParty"),$_SERVER["PHP_SELF"],"s.nom","",$param,'',$sortfield,$sortorder); @@ -527,6 +528,8 @@ if ($result) } print '
'; + print ''; + print "\n"; $db->free($result); } diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c4cd1b53d71..1afd69b73e0 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -81,7 +81,7 @@ LT2PaymentES=IRPF Payment LT2PaymentsES=IRPF Payments VATPayment=Sales tax payment VATPayments=Sales tax payments -VATRefund=Sales tax refund Refund +VATRefund=Sales tax refund Refund=Refund SocialContributionsPayments=Social/fiscal taxes payments ShowVatPayment=Show VAT payment From 433ad9d59d56a1bd9ca9b8232910b98f38c76c5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 13:27:17 +0100 Subject: [PATCH 3/7] Fix responsive --- htdocs/compta/paiement/avalider.php | 45 ++++++++++++++++++-------- htdocs/compta/paiement/card.php | 17 ++++++++-- htdocs/compta/paiement/cheque/card.php | 8 +++-- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/paiement/avalider.php b/htdocs/compta/paiement/avalider.php index 02201093830..a244a1feb60 100644 --- a/htdocs/compta/paiement/avalider.php +++ b/htdocs/compta/paiement/avalider.php @@ -38,22 +38,29 @@ if ($user->societe_id > 0) } -/* - * Affichage - */ - -llxHeader(); - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + + +/* + * Actions + */ + + + +/* + * View + */ + +llxHeader(); $sql = "SELECT p.rowid, p.datep as dp, p.amount, p.statut"; $sql.=", c.libelle as paiement_type, p.num_paiement"; @@ -70,10 +77,20 @@ if ($socid) $sql.= " AND f.fk_soc = ".$socid; } $sql.= " AND p.statut = 0"; -$sql.= " ORDER BY $sortfield $sortorder"; -$sql.= $db->plimit($limit+1, $offset); -$resql = $db->query($sql); +$sql.= $db->order($sortfield,$sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit + 1,$offset); + +$resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 07b8d95ddbc..7de97eba2e0 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -199,11 +199,12 @@ if ($action == 'valide') } -print ''; $linkback = '' . $langs->trans("BackToList") . ''; +print '
'."\n"; + // Ref print '
'.$langs->trans('Ref').''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); @@ -280,6 +281,8 @@ if (! empty($conf->banque->enabled)) print '
'; +dol_fiche_end(); + /* * List of invoices @@ -298,7 +301,14 @@ if ($resql) $i = 0; $total = 0; - print '
'; + + $moreforfilter=''; + + print '
'; + + print '
'; + print '
'; + print ''; print ''; print ''; @@ -363,6 +373,8 @@ if ($resql) $var=!$var; print "
'.$langs->trans('Bill').''.$langs->trans('Company').'
\n"; + print ''; + $db->free($resql); } else @@ -370,7 +382,6 @@ else dol_print_error($db); } -print ''; /* diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 94686162687..5b42fdb6825 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -471,7 +471,10 @@ if ($action == 'new') print ''; print ''; - print ''; + $moreforfilter=''; + print '
'; + print '
'."\n"; + print ''; print '\n"; @@ -539,7 +542,8 @@ if ($action == 'new') $i++; } print "
'.$langs->trans("DateChequeReceived").' '; print "
"; - + print ''; + print '
'; if ($user->rights->banque->cheque) { From 581b61bef182dab1b67dc92270da5fbe8c440d60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 14:55:41 +0100 Subject: [PATCH 4/7] CSS and look --- htdocs/contrat/card.php | 40 +++++++++++++++---------- htdocs/theme/eldy/img/play.png | Bin 653 -> 272 bytes htdocs/theme/eldy/img/playdisabled.png | Bin 828 -> 474 bytes htdocs/theme/eldy/img/playstop.png | Bin 0 -> 250 bytes htdocs/theme/md/img/play.png | Bin 131 -> 272 bytes htdocs/theme/md/img/playdisabled.png | Bin 828 -> 474 bytes htdocs/theme/md/img/playstop.png | Bin 0 -> 250 bytes 7 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 htdocs/theme/eldy/img/playstop.png create mode 100644 htdocs/theme/md/img/playstop.png diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index a27dbfbc71a..872dbc07784 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1470,11 +1470,11 @@ else $objp = $db->fetch_object($result); - $var=!$var; + //$var=!$var; if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { - print ''; + print ''; // Libelle if ($objp->fk_product > 0) { @@ -1563,7 +1563,7 @@ else $colspan = 7; } - print ''; + print ''; print ''; // Date planned @@ -1599,10 +1599,10 @@ else // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; + print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid,$extralabelslines); - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan)); + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } } @@ -1610,7 +1610,7 @@ else else { // Ligne carac - print ""; + print ""; print ''; if ($objp->fk_product) { @@ -1664,7 +1664,7 @@ else if($conf->global->PRODUCT_USE_UNITS) $colspan++; // Ligne dates prevues - print ""; + print ""; print ''; print $langs->trans("DateStartPlanned").' '; $form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update"); @@ -1673,10 +1673,10 @@ else print ''; if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; + print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid,$extralabelslines); - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan)); + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } @@ -1692,7 +1692,7 @@ else if ($object->statut > 0) { - print ''; + print ''; print '
'; print "\n"; } @@ -1761,7 +1761,7 @@ else { print ''; - print ''; + print ''; print ''; print ''; print "\n"; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/theme/eldy/img/play.png b/htdocs/theme/eldy/img/play.png index 4922ea1ec12a8606851317be0927fa7c83132889..b506d9eb9b98478758a3d46127a0d455d9ca911b 100644 GIT binary patch literal 272 zcmV+r0q_2aP)QL0yY4P1p~_6h70wFazUx zsfoF{iNr%SdpF^4aywOb+D^_EdP++AmM)H3L^UVhnuyvmnN(r#tO@F(j;k#|>Sh6W zxAy{IC6@pbL9d8{FAcyzFb3v=Qj7#Y-auI}`#*XuqG?>$kC9Iez)&y(61im&eZ<49 z7i~}%bzN-~s*W-pL|sP*2~kVtVr8JLY-sK3py5txD;FQUk$5OEHZwI+@vL9= Wa87Y#wAdy90000 literal 653 zcmV;80&@L{P)c8BOlfbI$K#7JzXv8rz9tLeSw=&&{vy+ zAX{t$K@Lf#{_!}zfVLSPBSp#ZPhZe{kj5nrPIvhn+m1mpDd=0ET!`0}hHN9-z3X#w z7G!;n*58dhLbt*&%D&>7_*|D2$6uwuApkw_teg^^HRmB%(3CZP*Z^3b=Z)x~N@?91mxwIso5d08ZM#q761; zv*L^F@xCPOAIsVVlI8K+a>K(x=32s_H=z>kh!NOF2>|&AZ#Eg}zwVfHZV-UjG5t*- z_-Vj!K7Gu;^<}aT`IdgnW%NZH$kh&j+YbPN?|i17hyxjci8FB4suneh?D7_ORLJz|u8)DF z5@@$wlblat=pcG+DQVX)_j5;q;(O4!4jEff`2h4cG|qFMDqg+E0>?1TiZwF`+T{`A_2zJOpfW2cW0@&b}p z@COUYf%pg#n~(>v2q@Q1Yl+$`3ffFyUGJ3?IF?y9O4ork3lBQxJGrI*gfIM*Utu-HP890tA*_YIiG#-)N04G32 zQZB4$)dzc#(v1Pvk_r*t1V(|Ckf<+llHrDelkEmr|L)8W)dq;qENnP1e;YtCgCGHx z%uE5+zk44NwcTvnDI^VG+05=De8>Ok#Qr#!^y)q#OMb`aB)v&GOLKM=cmZ0HW?kmT zG!ozv=mE9VU31%C0Xg8*B~F5w>;QXCvKF>Gl(F>(K*fC$FKq*;#jn6`&q&VAHsccC g106Ga;XmUG1b={vt<8 delta 794 zcmV+#1LgeM1H1+yiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUZy)f8YrU z5icZ*#wN@F00PNLL_t(I%Wad-Yg|pqx9z~BCF;@mgQg76Aq?+%fCAmbUlzq)w zdkrD(#=SC6LAj7QD=L>yzIa8*^eZTcFKn5y!hm;f`tcr6sFsu~fw3LF6V zE7!h}-%w9h)nBZ&2M6Qn{47NBKxnMx`9 z48mt&7#;#(!GC^3WkFE#F9K9b*=GS3#x^T4DEe(d(XW;ZnZ&=d0a*6CnQcDNXsykN z$lJ!4lNeKZe<-;EaBzO=>ldxH$5pi-NVy5`{IcIgM|$yznSP(x&T}8nGd20u>y3@E zNt8YjF@OOctLiMmkQ?_N-aOMy@8=8ucjI@T?B>YX>+Ab(C)yn&Th@igLpSbKpJuRs Y013z|y6m7?)&Kwi07*qoM6N<$g22;$Q2+n{ diff --git a/htdocs/theme/eldy/img/playstop.png b/htdocs/theme/eldy/img/playstop.png new file mode 100644 index 0000000000000000000000000000000000000000..72031b31b5df5076f3cfc3474a46e7d855adf292 GIT binary patch literal 250 zcmV`r2ydUmLxFra0DnkZNN-4du`Zh z1Yju|Wuu8`0hFRvHfoF3|A|)b=f>G+Dw+d9W1Efk8XbU>yMfe?hXVjzwaPF_Y8L?j z`YLxj6K!o%dk+_15{0A2`-2aHtYBenWv=5>f1Te^LLh`H;Q#;t07*qoM6N<$f><|X A(EtDd literal 0 HcmV?d00001 diff --git a/htdocs/theme/md/img/play.png b/htdocs/theme/md/img/play.png index 96021dc5081e1daa4d37cd649d720e676c27ecec..b506d9eb9b98478758a3d46127a0d455d9ca911b 100644 GIT binary patch delta 244 zcmVGn<$paEz~X-5XDl& zc&Ow8arFj4U5hVG*bl@MKGVK11LJwAiMhFn#6vZEH{ow`J5_huPR$kC9Iez)&y(61im&eZ<497i~}%bzN-~s*W-pL|sP*2~kVtVr8JL uY-sK3py5txD;FQUk$5OEHZwI+@vL9=a87Y#wAdy90000|Qz(b6phYa3?75xXol?>tp6oKJ8hGe{o;BY^K zDsDvx_?@AOft9eLNqg+E0>?1TiZwF`+T{`A_2zJOpfW2cW0@&b}p z@COUYf%pg#n~(>v2q@Q1Yl+$`3ffFyUGJ3?IF?y9O4ork3lBQxJGrI*gfIM*Utu-HP890tA*_YIiG#-)N04G32 zQZB4$)dzc#(v1Pvk_r*t1V(|Ckf<+llHrDelkEmr|L)8W)dq;qENnP1e;YtCgCGHx z%uE5+zk44NwcTvnDI^VG+05=De8>Ok#Qr#!^y)q#OMb`aB)v&GOLKM=cmZ0HW?kmT zG!ozv=mE9VU31%C0Xg8*B~F5w>;QXCvKF>Gl(F>(K*fC$FKq*;#jn6`&q&VAHsccC g106Ga;XmUG1b={vt<8 delta 794 zcmV+#1LgeM1H1+yiBL{Q4GJ0x0000DNk~Le0000G0000G2nGNE03Y-JVUZy)f8YrU z5icZ*#wN@F00PNLL_t(I%Wad-Yg|pqx9z~BCF;@mgQg76Aq?+%fCAmbUlzq)w zdkrD(#=SC6LAj7QD=L>yzIa8*^eZTcFKn5y!hm;f`tcr6sFsu~fw3LF6V zE7!h}-%w9h)nBZ&2M6Qn{47NBKxnMx`9 z48mt&7#;#(!GC^3WkFE#F9K9b*=GS3#x^T4DEe(d(XW;ZnZ&=d0a*6CnQcDNXsykN z$lJ!4lNeKZe<-;EaBzO=>ldxH$5pi-NVy5`{IcIgM|$yznSP(x&T}8nGd20u>y3@E zNt8YjF@OOctLiMmkQ?_N-aOMy@8=8ucjI@T?B>YX>+Ab(C)yn&Th@igLpSbKpJuRs Y013z|y6m7?)&Kwi07*qoM6N<$g22;$Q2+n{ diff --git a/htdocs/theme/md/img/playstop.png b/htdocs/theme/md/img/playstop.png new file mode 100644 index 0000000000000000000000000000000000000000..72031b31b5df5076f3cfc3474a46e7d855adf292 GIT binary patch literal 250 zcmV`r2ydUmLxFra0DnkZNN-4du`Zh z1Yju|Wuu8`0hFRvHfoF3|A|)b=f>G+Dw+d9W1Efk8XbU>yMfe?hXVjzwaPF_Y8L?j z`YLxj6K!o%dk+_15{0A2`-2aHtYBenWv=5>f1Te^LLh`H;Q#;t07*qoM6N<$f><|X A(EtDd literal 0 HcmV?d00001 From f875597c0bb083ae04a4698e64d8c6cc057cf517 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 16:03:08 +0100 Subject: [PATCH 5/7] Fix statistics of leave requests (date valid not defined if status is draft) --- htdocs/commande/stats/index.php | 91 +++++++++---------- .../class/expensereport.class.php | 4 +- .../class/expensereportstats.class.php | 18 ++-- htdocs/expensereport/stats/index.php | 24 +++-- htdocs/holiday/define_holiday.php | 7 +- 5 files changed, 80 insertions(+), 64 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 55b82d1063c..d900709b835 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -259,52 +259,50 @@ dol_fiche_head($head,'byyear',$langs->trans("Statistics")); print '
'; -//if (empty($socid)) -//{ - // Show filter box - print '
'; - print ''; - print '
'.$langs->trans("ServiceStatus").': '.$object->lines[$cursorline-1]->getLibStatut(4).''; if ($user->societe_id == 0) @@ -1769,10 +1769,18 @@ else if ($object->statut > 0 && $action != 'activateline' && $action != 'unactivateline') { $tmpaction='activateline'; - if ($objp->statut == 4) $tmpaction='unactivateline'; - if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) { + $tmpactionpicto='play'; + $tmpactiontext=$langs->trans("Activate"); + if ($objp->statut == 4) + { + $tmpaction='unactivateline'; + $tmpactionpicto='playstop'; + $tmpactiontext=$langs->trans("Unactivate"); + } + if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) + { print ''; - print img_edit(); + print img_picto($tmpactiontext, $tmpactionpicto); print ''; } } @@ -1780,7 +1788,7 @@ else print '
'; // Si pas encore active @@ -1903,7 +1911,7 @@ else print ''; - print '
'; + print '
'; print ''; print '
'; - print ''; - // Company - print ''; - // User - print ''; - // Year - print ''; - print ''; - print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; - if ($mode == 'customer') $filter='s.client in (1,2,3)'; - if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); - print '
'.$langs->trans("CreatedBy").''; - print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - // Status - print '
'.$langs->trans("Status").''; - if ($mode == 'customer') - { - $liststatus=array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSent"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") - ); - print $form->selectarray('object_status', $liststatus, GETPOST('object_status'), -4); - } - if ($mode == 'supplier') - { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',')?-1:$object_status), 0, 'object_status'); - } - print '
'.$langs->trans("Year").''; - if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; - arsort($arrayyears); - print $form->selectarray('year',$arrayyears,$year,0); - print '
'; - print ''; - print '

'; -//} +// Show filter box +print '
'; +print ''; +print ''; +print ''; +// Company +print ''; +// User +print ''; +// Year +print ''; +print ''; +print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; +if ($mode == 'customer') $filter='s.client in (1,2,3)'; +if ($mode == 'supplier') $filter='s.fournisseur = 1'; +print $form->select_company($socid,'socid',$filter,1,0,0,array(),0,'','style="width: 95%"'); +print '
'.$langs->trans("CreatedBy").''; +print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); +// Status +print '
'.$langs->trans("Status").''; +if ($mode == 'customer') +{ + $liststatus=array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraft"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_ACCEPTED=>$langs->trans("StatusOrderSent"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") + ); + print $form->selectarray('object_status', $liststatus, GETPOST('object_status'), -4); +} +if ($mode == 'supplier') +{ + $formorder->selectSupplierOrderStatus((strstr($object_status, ',')?-1:$object_status), 0, 'object_status'); +} +print '
'.$langs->trans("Year").''; +if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; +if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear; +arsort($arrayyears); +print $form->selectarray('year',$arrayyears,$year,0); +print '
'; +print '
'; +print '

'; + print ''; print ''; @@ -328,7 +326,6 @@ foreach ($data as $val) $var=!$var; print ''; print ''; - print ''; print ''; print ''; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e4a37cb5f62..574fde69c2a 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -489,7 +489,7 @@ class ExpenseReport extends CommonObject * Returns the label of a statut * * @param int $status id statut - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ function LibStatut($status,$mode=0) @@ -514,6 +514,8 @@ class ExpenseReport extends CommonObject if ($mode == 5) return ''.$langs->transnoentities($this->statuts_short[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]),$this->statuts_logo[$status]); + if ($mode == 6) + return $langs->transnoentities($this->statuts[$status]).' '.img_picto($langs->transnoentities($this->statuts_short[$status]),$this->statuts_logo[$status]); } diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 25ead4de0c1..d68483cb32b 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -59,9 +59,9 @@ class ExpenseReportStats extends Stats $this->from = MAIN_DB_PREFIX.$object->table_element." as e"; $this->field='total_ht'; - $this->where = " e.fk_statut > 0"; + //$this->where = " e.fk_statut > 0"; //$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have. - $this->where.= ' AND e.entity IN ('.getEntity('expensereport', 1).')'; + $this->where.= ' e.entity IN ('.getEntity('expensereport', 1).')'; //$this->where.= " AND entity = ".$conf->entity; if ($this->socid) @@ -88,7 +88,7 @@ class ExpenseReportStats extends Stats */ function getNbByYear() { - $sql = "SELECT YEAR(date_valid) as dm, count(*)"; + $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; $sql.= " GROUP BY dm DESC"; $sql.= " WHERE ".$this->where; @@ -105,7 +105,7 @@ class ExpenseReportStats extends Stats */ function getNbByMonth($year) { - $sql = "SELECT MONTH(e.date_valid) as dm, count(*)"; + $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; $sql.= " WHERE YEAR(e.date_valid) = ".$year; $sql.= " AND ".$this->where; @@ -126,9 +126,9 @@ class ExpenseReportStats extends Stats */ function getAmountByMonth($year) { - $sql = "SELECT date_format(e.date_valid,'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -146,9 +146,9 @@ class ExpenseReportStats extends Stats */ function getAverageByMonth($year) { - $sql = "SELECT date_format(e.date_valid,'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(e.date_valid,'%Y') = '".$year."'"; + $sql.= " WHERE date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') = '".$year."'"; $sql.= " AND ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -163,7 +163,7 @@ class ExpenseReportStats extends Stats */ function getAllByYear() { - $sql = "SELECT date_format(e.date_valid,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL','e.date_create','e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index b92405424c6..c81996fda3b 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -33,6 +33,9 @@ $langs->load("companies"); $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); +$mode=GETPOST("mode")?GETPOST("mode"):'customer'; +$object_status=GETPOST('object_status'); + $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); if ($socid < 0) $socid=0; $id = GETPOST('id','int'); @@ -52,7 +55,6 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear; $startyear=$year-1; $endyear=$year; -$mode=GETPOST("mode")?GETPOST("mode"):'customer'; /* @@ -60,18 +62,19 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer'; */ $form=new Form($db); - -llxHeader(); +$tmpexpensereport=new ExpenseReport($db); $title=$langs->trans("TripsAndExpensesStatistics"); $dir=$conf->expensereport->dir_temp; +llxHeader('', $title); + print load_fiche_titre($title, $mesg); dol_mkdir($dir); $stats = new ExpenseReportStats($db, $socid, $userid); - +if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$object_status.')'; // Build graphic number of object // $data = array(array('Lib',val1,val2,val3),...) @@ -227,6 +230,11 @@ $include=''; if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include='hierarchy'; print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; +// Status +print ''; // Year print ''; print ''; $oldyear=0; +$var=true; foreach ($data as $val) { $year = $val['year']; while ($year && $oldyear > $year+1) { // If we have empty year $oldyear--; - print ''; + $var=!$var; + print ''; print ''; print ''; print ''; print ''; print ''; } - print ''; + + $var=!$var; + print ''; print ''; print ''; print ''; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index cd0c3fc1598..414bcf709f4 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -221,6 +221,8 @@ else } print ''; + + // User print ''; + // Amount for each type if (count($typeleaves)) { foreach($typeleaves as $key => $val) @@ -249,8 +252,10 @@ else { print ''; } + + // Note print ''; print '
0?'&userid='.$userid:'').'">'.$oldyear.'00
'.$langs->trans("Status").''; +$liststatus=$tmpexpensereport->statuts; +print $form->selectarray('object_status', $liststatus, GETPOST('object_status'), -4, 0, 0, '', 1); +print '
'.$langs->trans("Year").''; if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year; @@ -247,20 +255,24 @@ print ''.$langs->trans("AmountAverage").'
'.$oldyear.'000
'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).'
'; $userstatic->id=$users['rowid']; $userstatic->lastname=$users['lastname']; @@ -232,6 +234,7 @@ else print $userstatic->getNomUrl(-1); print ''; - if ($canedit) print ''; + if ($canedit) print ''; print ''; if (! empty($user->rights->holiday->define_holiday)) From 34cf1fdd763b7bb97564716d3c59bc71fce51e23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 16:07:48 +0100 Subject: [PATCH 6/7] Fix if logo is not defined --- htdocs/cashdesk/index.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 4a892f909e5..9a61a50b38a 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -59,7 +59,18 @@ top_htmlhead('','',0,0,'',$arrayofcss);
From db220e7af59c56cc00961b347f3b7b5a3810261b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Jan 2017 20:55:26 +0100 Subject: [PATCH 7/7] FIX Rename api_key into DOLAPIKEY to allow to use it on http header. --- htdocs/api/class/api_access.class.php | 30 ++++++++++++++++--- htdocs/api/class/api_login.class.php | 10 ++++--- htdocs/api/index.php | 10 +++++++ .../Luracast/Restler/explorer/index.html | 15 +++++++--- htdocs/langs/en_US/admin.lang | 3 +- 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 68ec526ec7e..407f94ac915 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -76,12 +76,34 @@ class DolibarrApiAccess implements iAuthenticate $userClass = Defaults::$userIdentifierClass; + /*foreach ($_SERVER as $key => $val) + { + dol_syslog($key.' - '.$val); + }*/ + + // 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'])) + { + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['api_key']; // For backward compatibility + } + if (isset($_GET['DOLAPIKEY'])) + { + // TODO Add option to disable use of api key on url. Return errors if used. + $api_key = $_GET['DOLAPIKEY']; // With GET method + } + if (isset($_SERVER['HTTP_DOLAPIKEY'])) + { + $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) + } + + if ($api_key) { $sql = "SELECT u.login, u.datec, u.api_key, "; $sql.= " u.tms as date_modification, u.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.api_key = '".$db->escape($_GET['api_key'])."'"; + $sql.= " WHERE u.api_key = '".$db->escape($api_key)."'"; $result = $db->query($sql); if ($result) @@ -97,8 +119,8 @@ class DolibarrApiAccess implements iAuthenticate throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg); } - if ($stored_key != $_GET['api_key']) { - $userClass::setCacheIdentifier($_GET['api_key']); + if ($stored_key != $api_key) { + $userClass::setCacheIdentifier($api_key); return false; } @@ -121,7 +143,7 @@ class DolibarrApiAccess implements iAuthenticate } else { - throw new RestException(401, "Failed to login to API. No parameter 'api_key' provided"); + throw new RestException(401, "Failed to login to API. No parameter 'DOLAPIKEY' on HTTP header (neither in URL)."); } $userClass::setCacheIdentifier(static::$role); diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 439308fcaea..704ec1b6874 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -34,12 +34,14 @@ class Login /** * Login * - * Log user with username and password. Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass) - * - * @param string $login Username + * Request the API token for a couple username / password. + * Using method POST is recommanded for security reasons (method GET is often logged by default by web servers with parameters so with login and pass into server log file). + * Both method are provided for developer conveniance. Best is to not use at all the login API method and enter directly the "api_key" into field at the top right of page (Note: "api_key" can be found/set on the user page). + * + * @param string $login User login * @param string $password User password * @param int $entity Entity (when multicompany module is used). Empty means 1=first company. - * @param int $reset Reset token (0=get current token, 1=ask a new token, meaning that all future access using current token will failed) + * @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access) * @return array Response status and user token * * @throws RestException diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 8ad60c4b340..37be4d8cc26 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -56,6 +56,16 @@ if (empty($conf->global->MAIN_MODULE_API)) exit; } +// Test if explorer is not disabled +if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($conf->global->API_EXPLORER_DISABLED)) +{ + $langs->load("admin"); + dol_syslog("Call Dolibarr API interfaces with module REST disabled"); + print $langs->trans("WarningAPIExplorerDisabled").'.

'; + exit; +} + + $api = new DolibarrApi($db); diff --git a/htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html b/htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html index 27f0d4f53da..a433b80056b 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html +++ b/htdocs/includes/restler/framework/Luracast/Restler/explorer/index.html @@ -2,8 +2,8 @@ Api Explorer - - + @@ -56,11 +56,18 @@ log("key: " + key); if(key && key.trim() != "") { log("added key " + key); - window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query")); + + window.authorizations.add("key", new ApiKeyAuthorization("DOLAPIKEY", key, "query")); + console.log("param api_key added with value "+key); + + window.authorizations.add("key2", new ApiKeyAuthorization("DOLAPIKEY", key, "header")); + console.log("header DOLAPIKEY added with value "+key); } }) + window.swaggerUi.load(); }); + @@ -70,7 +77,7 @@
-
+
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3ed88e8e29e..5fd1ae065ec 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1503,10 +1503,11 @@ EndPointIs=SOAP clients must send their requests to the Dolibarr endpoint availa ##### API #### ApiSetup=API module setup ApiDesc=By enabling this module, Dolibarr become a REST server to provide miscellaneous web services. -ApiProductionMode=Enable production mode (this will activate use of a caches for services management) +ApiProductionMode=Enable production mode (this will activate use of a cache for services management) ApiExporerIs=You can explore the APIs at url OnlyActiveElementsAreExposed=Only elements from enabled modules are exposed ApiKey=Key for API +WarningAPIExplorerDisabled=The API explorer has been disabled. API explorer is not required to provide API services. It is a tool for developer to find/test REST APIs. If you need this tool, go into setup of module API REST to activate it. ##### Bank ##### BankSetupModule=Bank module setup FreeLegalTextOnChequeReceipts=Free text on cheque receipts