diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 6a06aad080f..4711aac7222 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -423,7 +423,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas=$obj->canvas; - print $companystatic->getNomUrl(1,'customer',16); + print $companystatic->getNomUrl(1,'supplier',16); print ''; print ''.price($obj->total_ttc).''; $i++; @@ -729,7 +729,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas=$obj->canvas; - print $companystatic->getNomUrl(1, 'company', 44); + print $companystatic->getNomUrl(1, 'customer', 44); print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; @@ -828,7 +828,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->code_client = $obj->code_client; $companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->canvas=$obj->canvas; - print $companystatic->getNomUrl(1, 'company', 44); + print $companystatic->getNomUrl(1, 'customer', 44); print ''; print ''; print dol_print_date($db->jdate($obj->dp),'day').''."\n"; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 7b53d775cb6..f756d50ad2a 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -36,10 +36,10 @@ $id=GETPOST('account'); $ref=GETPOST('ref'); // Security check -$fieldid = (! empty($ref)?$ref:$id); -$fieldname = isset($ref)?'ref':'rowid'; +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); +$fieldtype = (! empty($ref) ? 'ref' :'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque',$fieldid,'bank_account','','',$fieldname); +$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype); $year_start=GETPOST('year_start'); $year_current = strftime("%Y",time()); @@ -146,7 +146,7 @@ $linkback = ''.$langs->trans("B // Ref print ''.$langs->trans("Ref").''; print ''; -if ($_GET["account"]) +if (!empty($id)) { if (! preg_match('/,/', $id)) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 31d9e4d67c1..0b18a40d022 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -919,7 +919,10 @@ class BonPrelevement extends CommonObject $row = $this->db->fetch_row($resql); $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1,0,2),2,"0",STR_PAD_LEFT); - $this->filename = $conf->prelevement->dir_output.'/receipts/'.$ref.'.xml'; + $dir=$conf->prelevement->dir_output.'/receipts'; + if (! is_dir($dir)) dol_mkdir($dir); + + $this->filename = $dir.'/receipts/'.$ref.'.xml'; // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; @@ -935,10 +938,6 @@ class BonPrelevement extends CommonObject { $prev_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_bons"); $this->id = $prev_id; - - $dir=$conf->prelevement->dir_output.'/receipts'; - $file=$filebonprev; - if (! is_dir($dir)) dol_mkdir($dir); } else { @@ -1034,7 +1033,7 @@ class BonPrelevement extends CommonObject // Generation of SEPA file $this->generate(); } - dol_syslog(__METHOD__."::End withdraw receipt, file ".$filebonprev, LOG_DEBUG); + dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } /* diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1363e5012aa..f4163a889f0 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 2016 Ferran Marcet * 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 @@ -687,7 +688,7 @@ class FormFile * * @param string $modulepart propal, facture, facture_fourn, ... * @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. - * @param string $filedir Directory to scan + * @param string $filedir Full path to directory to scan * @param string $filter Filter filenames on this regex string (Example: '\.pdf$') * @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles */ @@ -720,9 +721,6 @@ class FormFile if ($modulepart == 'export') { $relativepath = $file["name"]; } - if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_fournisseur') { - $relativepath = get_exdir($modulesubdir, 2,0,0,null,'invoice_supplier'). $modulesubdir. "/" . $file["name"]; - } // Show file name with link to download $out.= 'id=$objp->sendingid; $expedition->fetchObjectLinked($expedition->id,$expedition->element); //var_dump($expedition->linkedObjects); + $receiving=''; if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 8729834ec3e..d8bb890c0dd 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -448,6 +448,18 @@ if ($object->id > 0) } // TODO move to DAO class + $sql = "SELECT count(p.rowid) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " WHERE p.fk_soc =".$object->id; + $sql.= " AND p.entity =".$conf->entity; + $sql.= " ORDER BY p.date_commande DESC"; + $resql=$db->query($sql); + if ($resql) + { + $object_count = $db->fetch_object($resql); + $num = $object_count->total; + } + $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$object->id; @@ -458,7 +470,6 @@ if ($object->id > 0) if ($resql) { $i = 0 ; - $num = $db->num_rows($resql); if ($num > 0) { @@ -474,7 +485,7 @@ if ($object->id > 0) } $var = True; - while ($i < $num && $i <= $MAXLIST) + while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); $var=!$var; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 88f01c1e837..9412c5eb015 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -743,17 +743,20 @@ if ($resql) $facturestatic->ref_supplier=$obj->ref_supplier; $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; - + print ''; if (! empty($arrayfields['f.ref']['checked'])) { print ''; - + print $facturestatic->getNomUrl(1); $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink('facture_fournisseur', $filename, $filedir); - print "\n"; + $subdir = get_exdir($obj->facid,2,0,0,$facturestatic,'invoice_supplier').dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); + + print "\n"; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index e7ce1625aad..ed3311a1b30 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -666,9 +666,13 @@ else $filteronlist=''; if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST; $text=$form->select_thirdparty_list($object->thirdparty->id, 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), '', 0, 0, 'minwidth300'); - $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); - print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); - print ''; + if (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) && empty($conf->dol_use_jmobile)) + { + $texthelp=$langs->trans("IfNeedToUseOhterObjectKeepEmpty"); + print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1, 0, '', '', 2); + } + else print $text; + print ''; } // Visibility diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 236a8154578..f29122f1c24 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1145,6 +1145,7 @@ class Project extends CommonObject // Load source object $clone_project->fetch($fromid); + $clone_project->fetch_optionals(); $clone_project->fetch_thirdparty(); $orign_dt_start=$clone_project->date_start; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b69c731a1d7..c4dd53315a3 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -53,7 +53,7 @@ $projectstatic = new Project($db); * Actions */ -if ($action == 'addtimespent' && $user->rights->projet->creer) +if ($action == 'addtimespent' && $user->rights->projet->lire) { $error=0; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 70dee1ab8eb..a5fae415a6a 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -276,7 +276,7 @@ if ($type_element == 'contract') $thirdTypeSelect='customer'; } -if ($sql_select) +if (!empty($sql_select)) { $sql = $sql_select; $sql.= ' d.description as description,'; @@ -302,7 +302,7 @@ if ($sql_select) $sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; } if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; - if ($sprod_fulldescr) + if ($sprod_fulldescr) { $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 4e88233fe35..514e8d0b28c 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -141,8 +141,7 @@ class UserBankAccount extends Account $sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; $sql.= " owner_address, label, datec, tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rib"; - if ($id) $sql.= " WHERE rowid = ".$id; - if ($socid) $sql.= " WHERE fk_user = ".$userid; + $sql.= " WHERE rowid = ".$id; $resql = $this->db->query($sql); if ($resql)