diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index a24ed34e052..e25ceb976ff 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -205,36 +205,42 @@ if ($action == 'create') { print '
'; print '' . "\n"; print '' . "\n"; - + + dol_fiche_head(); + print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; - print '
'; - print ''; - + + dol_fiche_end(); + + print '
'; + print '     '; + print '
'; + print '
'; } else diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 487f4dc2719..d3d6ff8a945 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +44,6 @@ if ($user->societe_id > 0) /* * Actions */ - if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { if (! GETPOST('cancel', 'alpha')) { @@ -63,6 +62,10 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { } } +/* + * View + */ + llxHeader("", "", "FicheVentilation"); if ($cancel == $langs->trans("Cancel")) { @@ -108,6 +111,8 @@ if (! empty($id)) { $linkback=''.$langs->trans("Back").''; print_fiche_titre($langs->trans('CustomersVentilation'),$linkback,'title_setup'); + dol_fiche_head(); + print ''; // Ref facture @@ -120,13 +125,13 @@ if (! empty($id)) { print ''; print ''; print ''; print '
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; - print $objp->account_number . '-' . $objp->label; - print '
' . $langs->trans("NewAccount") . ''; print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; + + dol_fiche_end(); - print '
'; + print '
'; print ''; print '     '; print ''; @@ -144,4 +149,4 @@ if (! empty($id)) { } llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index df635155416..5a1ffc30bb7 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -172,8 +172,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - - print '' . length_accountg($row[0]) . ''; + $var=!$var; + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; print '' . price($row[3]) . ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3a368f8d3ad..7941a7df4a8 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -43,7 +43,7 @@ $search_facture = GETPOST('search_facture','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); -$search_acount = GETPOST('search_account','alpha'); +$search_account = GETPOST('search_account','alpha'); // Security check if ($user->societe_id > 0) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index fc3157c318a..75e54b2a590 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -555,9 +555,9 @@ else $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal; $head[$h][1] = $langs->trans("Report"); - $head[$h][2] = 'report'; + $head[$h][2] = 'card'; - dol_fiche_head($head, $hselected); + dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment'); print '
'; print ''; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 51d09428c25..42837680428 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -1,11 +1,11 @@ * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -34,31 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; // Langs -$langs->load("compta"); $langs->load("bills"); -$langs->load("other"); -$langs->load("main"); $langs->load("accountancy"); -$action = GETPOST('action'); -$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); $codeventil = GETPOST('codeventil'); +$id = GETPOST('id'); // Security check if ($user->societe_id > 0) accessforbidden(); -if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) -{ - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; - - dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql); - - $resql = $db->query($sql); - if (! $resql) { - setEventMessage($db->lasterror(), 'errors'); +if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { + if (! GETPOST('cancel', 'alpha')) + { + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql .= " SET fk_code_ventilation = " . $codeventil; + $sql .= " WHERE rowid = " . $id; + + dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql); + $resql = $db->query($sql); + if (! $resql) { + setEventMessage($db->lasterror(), 'errors'); + } + } else { + header("Location: ./lines.php"); + exit(); } } @@ -78,7 +79,7 @@ $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); $formventilation = new FormVentilation($db); -if ($_GET["id"]) { +if (! empty($id)) { $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= ", aa.account_number, aa.label"; @@ -87,11 +88,14 @@ if ($_GET["id"]) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; + if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } + dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); + if ($result) { $num_lines = $db->num_rows($result); $i = 0; @@ -103,7 +107,10 @@ if ($_GET["id"]) { print ''; print ''; - print_fiche_titre($langs->trans("SuppliersVentilation")); + $linkback=''.$langs->trans("Back").''; + print_fiche_titre($langs->trans('SuppliersVentilation'),$linkback,'title_setup'); + + dol_fiche_head(); print '
'; @@ -119,19 +126,24 @@ if ($_GET["id"]) { print ''; print ''; print ''; - print ''; - print '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; - print $objp->account_number . '-' . $objp->label; - print '
' . $langs->trans("NewAccount") . ''; print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
 
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + print '
'; } else { - print "Error 1"; + print "Error"; } } else { - print "Error 2"; + print "Error"; } } else { print "Error ID incorrect"; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3bdf2f45a7c..2c2392bfa27 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -158,8 +158,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - - print '' . length_accountg($row[0]) . ''; + $var=!$var; + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; print '' . price($row[3]) . ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 9cf77779bf4..0edc9e1142f 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -44,7 +44,7 @@ $search_facture = GETPOST('search_facture','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); -$search_acount = GETPOST('search_account','alpha'); +$search_account = GETPOST('search_account','alpha'); // Security check if ($user->societe_id > 0) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 2b50008d58a..53937687b57 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -121,7 +121,7 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml'])) $pathtodelete=$listofpaths[$keytodelete]; $filetodelete=$listofnames[$keytodelete]; $result = dol_delete_file($pathtodelete,1); - if ($result >= 0) + if ($result) { setEventMessage($langs->trans("FileWasRemoved"), $filetodelete); diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 9003a92cddf..e40caa3e36e 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -89,7 +89,7 @@ if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allf // If (file that is not logfile) or (if logfile with option logfile) if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile') { - $count+=dol_delete_file($filesarray[$key]['fullname']); + $count+=(dol_delete_file($filesarray[$key]['fullname'])?1:0); } } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 88d6bb587e4..f765284f27e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1759,10 +1759,8 @@ if (empty($reshook)) $upload_dir = $conf->facture->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); $action = ''; } } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index dd48b27684f..192a2d16b17 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -823,10 +823,8 @@ else if ($action == 'remove_file' && $user->rights->contrat->creer) { $upload_dir = $conf->contrat->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0bd0625ee5d..10f91a07631 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -525,9 +525,9 @@ abstract class CommonObject * Return array with list of possible values for type of contacts * * @param string $source 'internal', 'external' or 'all' - * @param string $order Sort order by : 'code' or 'rowid' - * @param string $option 0=Return array id->label, 1=Return array code->label - * @param string $activeonly 0=all status of contact, 1=only the active + * @param string $order Sort order by 'code' or 'rowid' + * @param int $option 0=Return array id->label, 1=Return array code->label + * @param int $activeonly 0=all status of contact, 1=only the active * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ @@ -541,7 +541,7 @@ abstract class CommonObject $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE tc.element='".$this->element."'"; - if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active type + if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$source."'"; if (! empty($code)) $sql.= " AND tc.code='".$code."'"; $sql.= " ORDER by tc.".$order; @@ -626,12 +626,12 @@ abstract class CommonObject } /** - * Charge le contact d'id $id dans this->contact + * Load object contact with id=$this->contactid into $this->contact * * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid='') + function fetch_contact($contactid=null) { if (empty($contactid)) $contactid=$this->contactid; @@ -858,14 +858,14 @@ abstract class CommonObject /** * Update a specific field into database * - * @param string $field Field to update - * @param mixed $value New value - * @param string $table To force other table element or element line (should not be used) - * @param int $id To force other object id (should not be used) - * @param string $format Data format ('text', 'date'). 'text' is used if not defined - * @param string $id_field To force rowid field name. 'rowid' is used it not defined - * @param string $user Update last update fields also if user object provided - * @return int <0 if KO, >0 if OK + * @param string $field Field to update + * @param mixed $value New value + * @param string $table To force other table element or element line (should not be used) + * @param int $id To force other object id (should not be used) + * @param string $format Data format ('text', 'date'). 'text' is used if not defined + * @param string $id_field To force rowid field name. 'rowid' is used it not defined + * @param User|string $user Update last update fields also if user object provided + * @return int <0 if KO, >0 if OK */ function setValueFrom($field, $value, $table='', $id='', $format='', $id_field='', $user='') { @@ -1655,10 +1655,10 @@ abstract class CommonObject * @param int $exclspec >0 = Exclude special product (product_type=9) * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object. - * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object. + * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object and for this, we need seller object. * @return int <0 if KO, >0 if OK */ - function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='') + function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null) { global $conf; @@ -2684,9 +2684,9 @@ abstract class CommonObject * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * * @param string $action Action code - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected + * @param Societe $seller Object of seller third party + * @param Societe $buyer Object of buyer third party + * @param int $selected Object line selected * @param int $dateSelector 1=Show also date range input fields * @return void */ @@ -2799,16 +2799,16 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output - * @param string $var Is it a an odd line (true) - * @param int $num Number of line (0) - * @param int $i I - * @param int $dateSelector 1=Show also date range input fields - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party - * @param string $selected Object line selected - * @param object $extrafieldsline Object of extrafield line attribute + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output + * @param string $var Is it a an odd line (true) + * @param int $num Number of line (0) + * @param int $i I + * @param int $dateSelector 1=Show also date range input fields + * @param Societe $seller Object of seller third party + * @param Societe $buyer Object of buyer third party + * @param int $selected Object line selected + * @param object $extrafieldsline Object of extrafield line attribute * @return void */ function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) @@ -3086,7 +3086,7 @@ abstract class CommonObject /** * get Margin info * - * @param string $force_price True of not + * @param boolean $force_price True of not * @return mixed Array with info */ function getMarginInfos($force_price=false) @@ -3212,7 +3212,7 @@ abstract class CommonObject /** * Show the array with all margin infos * - * @param string $force_price Force price + * @param boolean $force_price Force price * @return void */ function displayMarginInfos($force_price=false) @@ -3304,7 +3304,7 @@ abstract class CommonObject /** * Add resources to the current object : add entry into llx_element_resources - *Need $this->element & $this->id + * Need $this->element & $this->id * * @param int $resource_id Resource id * @param string $resource_element Resource element @@ -3726,7 +3726,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeSize = $extrafields->attribute_size[$attributeKey]; + //$attributeSize = $extrafields->attribute_size[$attributeKey]; Not required to insert an extrafield value. Only used for definition. $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey]; switch ($attributeType) @@ -3751,19 +3751,19 @@ abstract class CommonObject case 'datetime': $this->array_options[$key]=$this->db->idate($this->array_options[$key]); break; - case 'link': - $param_list=array_keys($attributeParam ['options']); - // 0 : ObjectName - // 1 : classPath - $InfoFieldList = explode(":", $param_list[0]); - dol_include_once($InfoFieldList[1]); - $object = new $InfoFieldList[0]($this->db); - if ($value) - { - $object->fetch(0,$value); - $this->array_options[$key]=$object->id; - } - break; + case 'link': + $param_list=array_keys($attributeParam ['options']); + // 0 : ObjectName + // 1 : classPath + $InfoFieldList = explode(":", $param_list[0]); + dol_include_once($InfoFieldList[1]); + $object = new $InfoFieldList[0]($this->db); + if ($value) + { + $object->fetch(0,$value); + $this->array_options[$key]=$object->id; + } + break; } } $this->db->begin(); @@ -3771,6 +3771,7 @@ abstract class CommonObject $sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields WHERE fk_object = ".$this->id; dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG); $this->db->query($sql_del); + $sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object"; foreach($this->array_options as $key => $value) { @@ -3825,7 +3826,7 @@ abstract class CommonObject * * @return string */ - function showOptionals($extrafields, $mode='view', $params=0, $keyprefix='') + function showOptionals($extrafields, $mode='view', $params=null, $keyprefix='') { global $_POST, $conf; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index e2313d157d5..34abeeb8c6e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,7 +39,7 @@ class ExtraFields var $attribute_type; // Tableau contenant le nom des champs en clef et le label de ces champs en value var $attribute_label; - // Tableau contenant le nom des champs en clef et la taille de ces champs en value + // Tableau contenant le nom des champs en clef et la taille/longueur max de ces champs en value var $attribute_size; // Tableau contenant le nom des choix en clef et la valeur de ces choix en value var $attribute_choice; @@ -124,6 +124,7 @@ class ExtraFields if (empty($label)) return -1; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; // Create field into database except for separator type which is not stored in database if ($type != 'separate') @@ -169,6 +170,7 @@ class ExtraFields private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0) { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -248,6 +250,7 @@ class ExtraFields global $conf; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; // Clean parameters if (empty($pos)) $pos=0; @@ -308,6 +311,7 @@ class ExtraFields function delete($attrname, $elementtype='member') { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -342,6 +346,7 @@ class ExtraFields global $conf; if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { @@ -389,6 +394,7 @@ class ExtraFields function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='') { if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $table=$elementtype.'_extrafields'; @@ -486,6 +492,8 @@ class ExtraFields // Clean parameters if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; + if (empty($list)) $list=0; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) @@ -570,6 +578,7 @@ class ExtraFields if ( empty($elementtype) ) return array(); if ($elementtype == 'thirdparty') $elementtype='societe'; + if ($elementtype == 'contact') $elementtype='socpeople'; $array_name_label=array(); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 47810e204bd..ee7742660c1 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -116,9 +116,9 @@ class HookManager * @param array $parameters Array of parameters * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For doActions,formObjectOptions,pdf_xxx: Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 means KO. - * For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Deprecated. Must always return an int and things to print into ->resprints. - * Can also return some values into an array ->results. + * @return mixed For 'addreplace hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. + * All types can also return some values into an array ->results. * $this->error or this->errors are also defined by class called by this function if error. */ function executeHooks($method, $parameters=false, &$object='', &$action='') @@ -135,7 +135,8 @@ class HookManager array( 'addMoreActionsButtons', 'addStatisticLine', - 'doActions', + 'deleteFile', + 'doActions', 'formCreateThirdpartyOptions', 'formObjectOptions', 'formattachOptions', @@ -147,7 +148,7 @@ class HookManager 'formatEvent' ) )) $hooktype='addreplace'; - // Deprecated hook types + // Deprecated hook types ('returnvalue') if (preg_match('/^pdf_/',$method) && $method != 'pdf_writelinedesc') $hooktype='returnvalue'; // pdf_xxx except pdf_writelinedesc are 'returnvalue' hooks. When there is 2 hooks of this type, only last one win. TODO Move them into 'output' or 'addreplace' hooks. if ($method == 'insertExtraFields') { @@ -195,7 +196,7 @@ class HookManager if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results); if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints; } - // Generic hooks that return a string or array (printSearchForm, printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) + // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) else { // TODO. this should be done into the method of hook by returning nothing diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b4e5a8a0ec0..871821293b6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2825,7 +2825,7 @@ class Form /** * Creates HTML units selector (code => label) * - * @param string $selected Preselected code ('km', 'm', 'l', 'p', ...) + * @param string $selected Preselected Unit ID * @param string $htmlname Select name * @param int $showempty Add a nempty line * @return string HTML select @@ -2846,13 +2846,13 @@ class Form while($res = $this->db->fetch_object($resql)) { - if ($selected == $res[0]) + if ($selected == $res->rowid) { - $return.=''; + $return.=''; } else { - $return.=''; + $return.=''; } } $return.=''; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index daae392cd39..05fdcc96624 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -793,12 +793,12 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable /** * Remove a file or several files with a mask * - * @param string $file File to delete or mask of file to delete - * @param int $disableglob Disable usage of glob like * + * @param string $file File to delete or mask of files to delete + * @param int $disableglob Disable usage of glob like * so function is an exact delete function that will return error if no file found * @param int $nophperrors Disable all PHP output errors * @param int $nohook Disable all hooks * @param object $object Current object in use - * @return boolean True if file is deleted (or if glob is used and there's nothing to delete), False if error + * @return boolean True if no error (file is deleted or if glob is used and there's nothing to delete), False if error */ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null) { @@ -823,19 +823,20 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n $reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object); } - if (empty($nohook) && isset($reshook) && $reshook != '') // 0:not deleted, 1:deleted, null or '' for bypass + if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko { - return $reshook; + if ($reshook < 0) return false; + return true; } else { $error=0; //print "x".$file." ".$disableglob;exit; - $ok=true; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && ! empty($file_osencoded)) { + $ok=true; $globencoded=str_replace('[','\[',$file_osencoded); $globencoded=str_replace(']','\]',$globencoded); $listofdir=glob($globencoded); @@ -853,6 +854,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n } else { + $ok=false; if ($nophperrors) $ok=@unlink($file_osencoded); else $ok=unlink($file_osencoded); if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); @@ -958,9 +960,9 @@ function dol_delete_preview($object) if (file_exists($file) && is_writable($file)) { - if ( ! dol_delete_file($file,1) ) + if (! dol_delete_file($file,1)) { - $object->error=$langs->trans("ErrorFailedToOpenFile",$file); + $object->error=$langs->trans("ErrorFailedToDeleteFile",$file); return 0; } } diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 74da1f97ff0..36596165191 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -1,6 +1,6 @@ - * Copyright (C) 2007-2009 Regis Houssin +/* Copyright (C) 2007-2015 Laurent Destailleur + * Copyright (C) 2007-2015 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -58,6 +58,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= $sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'"; if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'"; $sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")"; + $sql.=' AND statut = 1'; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 25c6d2cd2ad..e477e086fe0 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -127,10 +127,10 @@ class mod_facture_mars extends ModeleNumRefFactures */ function getNextValue($objsoc,$facture,$mode='next') { - global $db,$conf; + global $db; $prefix=$this->prefixinvoice; - + if ($facture->type == 1) $prefix=$this->prefixreplacement; else if ($facture->type == 2) $prefix=$this->prefixcreditnote; else if ($facture->type == 3) $prefix=$this->prefixdeposit; @@ -141,7 +141,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('facture', 1).")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -165,7 +165,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('facture', 1).")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index dc06c6202ec..31d8eac736b 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2015 Regis Houssin * * 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 @@ -111,7 +111,7 @@ class mod_facture_terre extends ModeleNumRefFactures $this->error=$langs->trans('ErrorNumRefModel',$max); return false; } - + // Check deposit num $fayymm=''; @@ -146,7 +146,7 @@ class mod_facture_terre extends ModeleNumRefFactures */ function getNextValue($objsoc,$facture,$mode='next') { - global $db,$conf; + global $db; if ($facture->type == 2) $prefix=$this->prefixcreditnote; else if ($facture->type == 3) $prefix=$this->prefixdeposit; @@ -157,7 +157,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('facture', 1).")"; $resql=$db->query($sql); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); @@ -181,7 +181,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql = "SELECT facnumber as ref"; $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (".getEntity('facture', 1).")"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php index 36b6ce75fe1..40bd0a5368e 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -59,11 +59,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($urlfile) { $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) { - setEventMessage($langs->trans("FileWasRemoved", $urlfile)); - } else { - setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); - } + if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); } elseif ($linkid) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 70ebd8550c5..913b21bdd14 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3680,7 +3680,7 @@ function migrate_delete_old_files($db,$langs,$conf) print ' '.$langs->trans("RemoveItManuallyAndPressF5ToContinue").'
'; } else - { + { //print $langs->trans("FileWasRemoved",$filetodelete); } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 60384a29da0..b7ea6bd798b 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -698,7 +698,7 @@ else if ($action == 'edit' && $userWrite > 0) { print '
'; - print '     '; + print '     '; print ''; print '
'; } diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 4477784ae7d..e9fb713b857 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -339,10 +339,15 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertTrue($result,'delete file'); - // Again to test no error when deleteing a non existing file - $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); + // Again to test there is error when deleting a non existing file with option disableglob + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv',1,1); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file that does not exists'); + $this->assertFalse($result,'delete file that does not exists with disableglo must return ko'); + + // Again to test there is no error when deleting a non existing file without option disableglob + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result,'delete file that does not exists without disabling glob must return ok'); // Test copy with special char / delete with blob $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1);