diff --git a/dev/ansible/deployplaybook/deploydev.yml b/dev/ansible/deployplaybook/deploydev.yml new file mode 100644 index 00000000000..5802fb10a1e --- /dev/null +++ b/dev/ansible/deployplaybook/deploydev.yml @@ -0,0 +1,24 @@ +#!/usr/bin/env ansible-playbook + +# Run script with ansible-playbook deploydev.yml +# or ./deploydev.yml + +- name: Configure webserver with apache + hosts: webservers + sudo: True + tasks: + - name: install apache + apt: name=apache update_cache=yes + - name: copy apache config file + copy: src=files/apachealias.conf dest=/etc/apache/conf.d/dolibarr_dev + #- name: enable configuration + # file: > + # dest=/etc/apache/sites-enabled/default + # src=/etc/apache/sites-available/default + # state=link + - name: copy info.html + template: src=templates/info.html.j2 dest=/var/www/dolibarr_dev/info.html + mode=0644 + - name: restart apache + service: name=apache state=restarted + diff --git a/dev/ansible/deployplaybook/files/apachealias.conf b/dev/ansible/deployplaybook/files/apachealias.conf new file mode 100644 index 00000000000..d801094af5a --- /dev/null +++ b/dev/ansible/deployplaybook/files/apachealias.conf @@ -0,0 +1,2 @@ + +Alias /dolibarr_dev /var/www/dolibarr diff --git a/dev/ansible/deployplaybook/hosts b/dev/ansible/deployplaybook/hosts new file mode 100644 index 00000000000..99627faba2b --- /dev/null +++ b/dev/ansible/deployplaybook/hosts @@ -0,0 +1,2 @@ +[webservers] +testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=22 diff --git a/dev/ansible/deployplaybook/templates/info.html.j2 b/dev/ansible/deployplaybook/templates/info.html.j2 new file mode 100644 index 00000000000..66fac1c4deb --- /dev/null +++ b/dev/ansible/deployplaybook/templates/info.html.j2 @@ -0,0 +1,10 @@ + + + Page info ansible + + +

Apache, configured by Ansible

+

If you can see this, Ansible successfully installed apache.

+

{{ ansible_managed }}

+ + \ No newline at end of file diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0fe6366ae58..3659f476ca0 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -322,15 +322,15 @@ if (empty($reshook)) if ($result >= 0 && ! count($object->errors)) { // Logo/Photo save - $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos'; + $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (GETPOST('deletephoto')) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo; - $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs'; + $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/'.$object->photo; + $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'member').'/photos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 1d780eb21a5..71f1df22937 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -60,7 +60,6 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; -$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id,2,0,1) . '/' . $id; $form = new Form($db); $object=new Adherent($db); $membert=new AdherentType($db); @@ -70,6 +69,9 @@ if ($result < 0) dol_print_error($db); exit; } +$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'member') . '/' . dol_sanitizeFileName($object->ref); + + /* * Actions */ diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 671a9bf9eba..88184065574 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -439,6 +439,26 @@ print "\n";
" id="buttonGo" />

+ +'.$langs->trans("RunCommandSummary").':
'."\n"; + print '
'."\n"; + print '
'; + + //print $paramclear; + + // Now run command and show result + print ''.$langs->trans("BackupResult").': '; + print $_SESSION["commandbackupresult"]; + + $_SESSION["commandbackuplastdone"]=''; + $_SESSION["commandbackuptorun"]=''; + $_SESSION["commandbackupresult"]=''; +} +?> +
trans("Error")." : ".$errormsg, 'errors'); - /* - print '
'.$langs->trans("Error")." : ".$errormsg.'
'; - print '
'; - print '
';*/ + + $resultstring=''; + $resultstring.='
'.$langs->trans("Error")." : ".$errormsg.'
'; + + $_SESSION["commandbackupresult"]=$resultstring; } else { if ($what) { setEventMessage($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile")); - /*print '
'; - print $langs->trans("BackupFileSuccessfullyCreated").'.
'; - print $langs->trans("YouCanDownloadBackupFile"); - print '
'; - print '
';*/ + + $resultstring='
'; + $resultstring.=$langs->trans("BackupFileSuccessfullyCreated").'.
'; + $resultstring.=$langs->trans("YouCanDownloadBackupFile"); + $resultstring.='
'; + + $_SESSION["commandbackupresult"]=$resultstring; } else { diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 373b46c6062..72280ec7220 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -1,6 +1,7 @@ - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -24,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (! $user->admin) accessforbidden(); @@ -59,6 +61,32 @@ $search_user = GETPOST("search_user"); $search_desc = GETPOST("search_desc"); $search_ua = GETPOST("search_ua"); +$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); +$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); + +// checks:if date_start>date_end then date_end=date_start + 24 hours +if ($date_start > $date_end) $date_end=$date_start+86400; + +$now = dol_now(); +$nowarray = dol_getdate($now); + +$params = "&search_code=$search_code&search_ip=$search_ip&search_user=$search_user&search_desc=$search_desc&search_ua=$search_ua"; +$params.= "&date_startmonth=".$_REQUEST["date_startmonth"]; +$params.= "&date_startday=".$_REQUEST["date_startday"]; +$params.= "&date_startyear=".$_REQUEST["date_startyear"]; +$params.= "&date_endmonth=".$_REQUEST["date_endmonth"]; +$params.= "&date_endday=".$_REQUEST["date_endday"]; +$params.= "&date_endyear=".$_REQUEST["date_endyear"]; + +if (empty($date_start)) // We define date_start and date_end +{ + $date_start=dol_get_first_day($nowarray['year'],$nowarray['mon'],false); +} +if (empty($date_end)) +{ + $date_end=dol_mktime(23,59,59,$nowarray['mon'],$nowarray['mday'],$nowarray['year']); +} + /* * Actions @@ -124,6 +152,7 @@ $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; $sql.= " WHERE e.entity IN (".getEntity('actioncomm', 1).")"; +$sql.= " AND e.dateevent >= '".$db->idate($date_start)."' AND e.dateevent <= '".$db->idate($date_end)."'"; if ($search_code) { $usefilter++; $sql.=" AND e.type LIKE '%".$db->escape($search_code)."%'"; } if ($search_ip) { $usefilter++; $sql.=" AND e.ip LIKE '%".$db->escape($search_ip)."%'"; } if ($search_user) { $usefilter++; $sql.=" AND u.login LIKE '%".$db->escape($search_user)."%'"; } @@ -145,7 +174,8 @@ if ($result) if ($search_desc) $param.='&search_desc='.$search_desc; if ($search_ua) $param.='&search_ua='.$search_ua; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, 'setup'); + $langs->load('withdrawals'); + print_barre_liste($langs->trans("ListOfSecurityEvents").' : '.$num.' '.strtolower($langs->trans("Lines")), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, 'setup'); if ($action == 'purge') { @@ -168,7 +198,7 @@ if ($result) print '
'; print ''; - print ' '; + print ''.$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).$form->select_date($date_end,'date_end',0,0,0,'',1,0,1).''; print ''; print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 20fce315153..96949371bae 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1302,7 +1302,7 @@ class Categorie extends CommonObject { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/"; + $dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/"; $dir .= "photos/"; if (! file_exists($dir)) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 76a19c91d7d..590cb4edb49 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin * @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("categories"); @@ -151,8 +152,7 @@ foreach($fulltree as $key => $val) 'rowid'=>$val['rowid'], 'fk_menu'=>$val['fk_parent'], 'entry'=>''. + ''. ''. '
'.$li. - ''. - ' '.$val['description'].''.dolGetFirstLineOfText($val['description']).''.img_view().'
' ); @@ -160,7 +160,7 @@ foreach($fulltree as $key => $val) print ''; -print '"; @@ -701,14 +698,14 @@ class FormFile if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... // Autre cas if ($modulepart == 'donation') { - $relativepath = get_exdir($modulesubdir,2).$file["name"]; + $relativepath = get_exdir($modulesubdir,2,0,0,null,'donation').$file["name"]; } if ($modulepart == 'export') { $relativepath = $file["name"]; } - if ($modulepart == 'facture_fournisseur') { - $relativepath = get_exdir($modulesubdir, 2). $modulesubdir. "/" . $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.= 'ref)?dol_sanitizeFileName($object->ref):'').'/'; - if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath; // TODO Call using a defined value for $relativepath - if ($object->element == 'member') $relativepath=get_exdir($object->id,2).$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'member') $relativepath=get_exdir($object->id,2,0,0,$object,'member').$relativepath; // TODO Call using a defined value for $relativepath if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0af5e917cc5..daae392cd39 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1399,7 +1399,7 @@ function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('(\.meta /** * Security check when accessing to a document (used by document.php, viewimage.php and webservices) * - * @param string $modulepart Module of document (module, module_user_temp, module_user or module_temp) + * @param string $modulepart Module of document ('module', 'module_user_temp', 'module_user' or 'module_temp') * @param string $original_file Relative path with filename * @param string $entity Restrict onto entity * @param User $fuser User object (forced) @@ -1817,7 +1817,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $accessallowed=1; } - $original_file=$conf->banque->dir_output.'/bordereau/'.get_exdir(basename($original_file,".pdf"),2,1).$original_file; + $original_file=$conf->banque->dir_output.'/bordereau/'.$original_file; // original_file should contains relative path so include the get_exdir result } // Wrapping for export module diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 3d605d10902..d350fbce175 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -69,7 +69,7 @@ function facturefourn_prepare_head($object) } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$object->ref; + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref; $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; $head[$h][1] = $langs->trans('Documents'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f067dcaf417..3d756fb8e32 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1127,19 +1127,6 @@ function dol_getdate($timestamp,$fast=false) else { $arrayinfo=getdate($timestamp); - - /*$startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; - if($startday==1) - { - if ($arrayinfo["wday"]==0) - { - $arrayinfo["wday"]=6; - } - else - { - $arrayinfo["wday"]=$arrayinfo["wday"]-1; - } - }*/ } return $arrayinfo; @@ -2886,14 +2873,14 @@ function print_fleche_navigation($page,$file,$options='',$nextpage=0,$betweenarr print '
'.$langs->trans("Categories").''.$langs->trans("Description").''; +print '
'.$langs->trans("Categories").''; if (! empty($conf->use_javascript_ajax)) { print ''; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 59be328c55e..eb496db1af9 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -224,7 +224,7 @@ if ($object->id) $maxWidth = 160; $maxHeight = 120; - $pdir = get_exdir($object->id,2) . $object->id ."/photos/"; + $pdir = get_exdir($object->id,2,0,0,$object,'category') . $object->id ."/photos/"; $dir = $upload_dir.'/'.$pdir; print '
'; diff --git a/htdocs/comm/askpricesupplier/card.php b/htdocs/comm/askpricesupplier/card.php index 14d00d43780..c49881ba542 100644 --- a/htdocs/comm/askpricesupplier/card.php +++ b/htdocs/comm/askpricesupplier/card.php @@ -847,13 +847,10 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); - } else { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); - exit(); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -1760,7 +1757,8 @@ if ($action == 'create') // Build document if it not exists if (! $file || ! is_readable($file)) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) { + if ($result <= 0) + { dol_print_error($db, $result); exit(); } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 7c08235e788..e8635ec4861 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -153,7 +153,7 @@ if (empty($reshook)) } else { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); if ($object->statut == 0) { @@ -398,7 +398,7 @@ if (empty($reshook)) { $error=0; - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); $object->sendto = $_POST["sendto"]; if (! $object->sendto) @@ -495,7 +495,7 @@ if (empty($reshook)) // Action update description of emailing if ($action == 'settitre' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha')); else if ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from','alpha')); @@ -527,7 +527,7 @@ if (empty($reshook)) */ if (! empty($_POST['addfile'])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -540,7 +540,7 @@ if (empty($reshook)) // Action remove file if (! empty($_POST["removedfile"])) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -719,7 +719,7 @@ else { if ($object->id > 0) { - $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1); + $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1,$object,'mailing'); $head = emailing_prepare_head($object); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 09c6087860c..5be006c0053 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1065,13 +1065,10 @@ if (empty($reshook)) } $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); - } else { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); - exit(); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6ff12430000..4b7d0104ec9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1091,10 +1091,10 @@ if (empty($reshook)) $outputlangs->setDefaultLang($newlang); } $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -1316,7 +1316,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; dol_fiche_head(''); - + print ''; // Reference @@ -1548,7 +1548,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '
'; dol_fiche_end(); - + // Button "Create Draft" print '
'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6621db1d241..88d6bb587e4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1743,8 +1743,8 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { - dol_print_error($db, $result); - exit(); + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -1970,7 +1970,7 @@ if ($action == 'create') print ''; dol_fiche_head(''); - + print ''; // Ref @@ -2475,7 +2475,7 @@ if ($action == 'create') print "
\n"; dol_fiche_end(); - + // Button "Create Draft" print '
'; print ''; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index dba17a4798c..49af748c115 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -262,7 +262,7 @@ else if ($action == 'remove_file' && $user->rights->banque->cheque) $langs->load("other"); - $file=$dir.get_exdir($object->number,2,1) . GETPOST('file'); + $file=$dir.get_exdir($object->number,2,1,0,$object,'cheque') . 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'); @@ -322,7 +322,7 @@ else if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete','','',1); - + } /* @@ -331,7 +331,7 @@ else if ($action == 'valide') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide','','',1); - + } } @@ -704,7 +704,7 @@ if ($action != 'new') if ($object->statut == 1) { $filename=dol_sanitizeFileName($object->ref); - $filedir=$dir.get_exdir($object->number,2,1) . dol_sanitizeFileName($object->ref); + $filedir=$dir.get_exdir($object->number,2,1,0,$object,'cheque') . dol_sanitizeFileName($object->ref); $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $formfile->show_documents('remisecheque', $filename, $filedir, $urlsource, 1, 1); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index cc9a394d983..dd48b27684f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -807,13 +807,10 @@ else if ($action == 'builddoc' && $user->rights->contrat->creer) { } $ret = $object->fetch($id); // Reload to get new records $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) { - dol_print_error($db, $result); - exit(); - } else { - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); - exit(); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 520ab7634be..cdb7f66ac5f 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -132,7 +132,7 @@ class FileUpload $object_ref = dol_sanitizeFileName($object->ref); if ($element == 'invoice_supplier') { - $object_ref = get_exdir($object->id, 2) . $object_ref; + $object_ref = get_exdir($object->id,2,0,0,$object,'invoice_supplier') . $object_ref; } else if ($element == 'project_task') { $object_ref = $object->project->ref . '/' . $object_ref; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 406ad24db4b..39634e6af31 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4806,19 +4806,19 @@ class Form else if ($modulepart=='userphoto') { $dir=$conf->user->dir_output; - if ($object->photo) $file=get_exdir($id, 2).$object->photo; + if ($object->photo) $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo; if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; } else if ($modulepart=='memberphoto') { $dir=$conf->adherent->dir_output; - if ($object->photo) $file=get_exdir($id, 2).'photos/'.$object->photo; + if ($object->photo) $file=get_exdir($id, 2, 0, 0, $object, 'invoice_supplier').'photos/'.$object->photo; if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; }else { $dir=$conf->$modulepart->dir_output; - if ($object->photo) $file=get_exdir($id, 2).'photos/'.$object->photo; + if ($object->photo) $file=get_exdir($id, 2, 0, 0, $adherent, 'member').'photos/'.$object->photo; if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index cecbefa0dd9..6aac42331bc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes - + * 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 * the Free Software Foundation; either version 3 of the License, or @@ -265,7 +265,6 @@ class FormFile if (! is_object($form)) $form=new Form($this->db); - // filedir = $conf->...->dir_ouput."/".get_exdir(id) include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // For backward compatibility @@ -579,11 +578,9 @@ class FormFile $var=!$var; // Define relative path for download link (depends on module) - $relativepath=$file["name"]; // Cas general + $relativepath=$file["name"]; // Cas general if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... - // Autre cas - if ($modulepart == 'donation') { $relativepath = get_exdir($modulesubdir,2).$file["name"]; } - if ($modulepart == 'export') { $relativepath = $file["name"]; } + if ($modulepart == 'export') $relativepath = $file["name"]; // Other case $out.= "
'; $nbrows=11; @@ -312,14 +316,14 @@ if ($action == 'create') print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; - + print "".''; // Public note print ''; print ''; print ''; @@ -337,9 +341,9 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { - + $formproject=new FormProjets($db); - + print "\n"; @@ -352,11 +356,11 @@ if ($action == 'create') { print $object->showOptionals($extrafields,'edit',$parameters); } - + print "
'.$langs->trans("EMail").'
' . $langs->trans('NotePublic') . ''; - + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); print $doleditor->Create(1); print '
".$langs->trans("Project").""; $formproject->select_projects(-1, GETPOST("fk_projet"),'fk_projet', 0, 0, 1, 1); print "
\n"; - + dol_fiche_end(); - + print '
   
'; print "\n"; @@ -380,6 +384,7 @@ if (! empty($id) && $action == 'edit') dol_print_error($db); exit; } + $hselected='card'; $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic'); @@ -441,7 +446,7 @@ if (! empty($id) && $action == 'edit') print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; - + print "".''.$langs->trans("EMail").''; print "".$langs->trans("PaymentMode")."\n"; @@ -458,7 +463,7 @@ if (! empty($id) && $action == 'edit') if (! empty($conf->projet->enabled)) { $formproject=new FormProjets($db); - + $langs->load('projects'); print ''.$langs->trans('Project').''; $formproject->select_projects(-1, $object->fk_projet,'fk_projet', 0, 1, 0, 1); @@ -497,7 +502,7 @@ if (! empty($id) && $action != 'edit') $text=$langs->trans("ConfirmDeleteADonation"); print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteADonation"),$text,"confirm_delete",'','',1); } - + $result=$object->fetch($id); if ($result < 0) { dol_print_error($db,$object->error); exit; @@ -506,7 +511,9 @@ if (! empty($id) && $action != 'edit') if ($result < 0) { dol_print_error($db); exit; } - + + $hselected='card'; + $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic'); @@ -542,7 +549,7 @@ if (! empty($id) && $action != 'edit') print ''.$langs->trans("Lastname").''.$object->lastname.''; print ''.$langs->trans("Firstname").''.$object->firstname.''; print ''.$langs->trans("Address").''.dol_nl2br($object->address).''; - + $rowspan=6; if (! empty($conf->projet->enabled)) $rowspan++; print ''; @@ -584,7 +591,7 @@ if (! empty($id) && $action != 'edit') print ""; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; - $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; print "".$labeltype.' '.$object->num_paiement."\n"; print ''.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; print ""; @@ -628,7 +635,7 @@ if (! empty($id) && $action != 'edit') else { print $object->country_olddata; - } + } print ''; // EMail @@ -683,12 +690,12 @@ if (! empty($id) && $action != 'edit') } // Create payment - if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer) + if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer) { - if ($remaintopay == 0) + if ($remaintopay == 0) { print '
' . $langs->trans('DoPayment') . '
'; - } + } else { print ''; @@ -700,7 +707,7 @@ if (! empty($id) && $action != 'edit') { print '"; } - + // Delete if ($user->rights->don->supprimer) { @@ -720,7 +727,7 @@ if (! empty($id) && $action != 'edit') * Documents generes */ $filename=dol_sanitizeFileName($object->id); - $filedir=$conf->don->dir_output . '/' . get_exdir($filename,2); + $filedir=$conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); $urlsource=$_SERVER['PHP_SELF'].'?rowid='.$object->id; // $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer); // $delallowed=$user->rights->facture->supprimer; @@ -730,7 +737,7 @@ if (! empty($id) && $action != 'edit') $var=true; print '
'; - $formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed); + $formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); print ' '; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 33706ddd841..e3910b6fe51 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -60,9 +60,10 @@ class Don extends CommonObject var $note_private; var $note_public; var $statut; - + var $modelpdf; var $projet; + /** * Constructor * @@ -306,14 +307,14 @@ class Don extends CommonObject * @return int <0 if KO, id of created donation if OK * TODO add numbering module for Ref */ - function create($user, $notrigger) + function create($user, $notrigger=0) { global $conf, $langs; - + $error = 0; $ret = 0; $now=dol_now(); - + // Clean parameters $this->address=($this->address>0?$this->address:$this->address); $this->zip=($this->zip>0?$this->zip:$this->zip); @@ -391,7 +392,7 @@ class Don extends CommonObject $this->errno = $this->db->lasterrno(); $error++; } - + // Update extrafield if (!$error) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used @@ -403,7 +404,7 @@ class Don extends CommonObject } } } - + if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { $res = $this->setValid($user); @@ -434,7 +435,7 @@ class Don extends CommonObject global $langs, $conf; $error=0; - + // Clean parameters $this->address=($this->address>0?$this->address:$this->address); $this->zip=($this->zip>0?$this->zip:$this->zip); @@ -523,11 +524,11 @@ class Don extends CommonObject { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $error = 0; - + $this->db->begin(); - + // Delete donation if (! $error) { @@ -601,7 +602,7 @@ class Don extends CommonObject $sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,"; $sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, "; $sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, "; - $sql.= " d.phone_mobile, d.fk_projet,"; + $sql.= " d.phone_mobile, d.fk_projet, d.model_pdf,"; $sql.= " p.title as project_label,"; $sql.= " c.code as country_code, c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; @@ -651,12 +652,13 @@ class Don extends CommonObject $this->public = $obj->public; $this->modepaymentid = $obj->fk_payment; $this->modepayment = $obj->libelle; - $this->paid = $obj->paid; + $this->paid = $obj->paid; $this->amount = $obj->amount; $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; $this->commentaire = $obj->note; // deprecated - + // Retrieve all extrafield for thirdparty // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -821,7 +823,7 @@ class Don extends CommonObject if ($withpicto != 2) $result.=$link.$this->id.$linkend; return $result; } - + /** * Information on record * diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index db8b236feaa..2475f420dd0 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -409,8 +409,8 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -611,7 +611,7 @@ if ($action == 'create') $liste = ModelePdfExpedition::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); print "\n"; - + // Other attributes $parameters=array('colspan' => ' colspan="3"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 41def896ac0..e0b5b791ada 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -497,7 +497,7 @@ class Expedition extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - $file = $conf->expedition->dir_output . "/" .get_exdir($this->id, 2) . "/" . $this->id.".pdf"; + $file = $conf->expedition->dir_output . "/" .get_exdir($this->id, 2, 0, 0, $this, 'shipment') . "/" . $this->id.".pdf"; $this->pdf_filename = $file; // Tracking url diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a9ccf2471db..2d9bcbceead 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1030,13 +1030,8 @@ if ($action == 'builddoc') // GET or POST $result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs); if ($result <= 0) { - dol_print_error($db,$result); - exit; - } - else - { - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$depl->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b1b9e74266e..ccd17a2f97b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2066,7 +2066,7 @@ class CommandeFournisseur extends CommonOrder $sql.= ",total_localtax2='".price2num($total_localtax2)."'"; $sql.= ",total_ttc='".price2num($total_ttc)."'"; $sql.= ",product_type=".$type; - $sql.= ($fk_unit ? "'".$this->db->escape($fk_unit)."'":"null"); + $sql.= ($fk_unit ? ",fk_unit='".$this->db->escape($fk_unit)."'":", fk_unit=null"); $sql.= " WHERE rowid = ".$rowid; dol_syslog(get_class($this)."::updateline", LOG_DEBUG); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0c5998d953c..994ddb28310 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -736,7 +736,7 @@ class FactureFournisseur extends CommonInvoice include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $ref = dol_sanitizeFileName($this->ref); - $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2).$ref; + $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoive_supplier').$ref; $file = $dir . "/" . $ref . ".pdf"; if (file_exists($file)) { @@ -975,8 +975,8 @@ class FactureFournisseur extends CommonInvoice $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$oldref; - $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$newref; + $dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2,0,0, $this, 'invoive_supplier').$oldref; + $dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2,0,0, $this, 'invoive_supplier').$newref; if (file_exists($dirsource)) { dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); @@ -985,7 +985,7 @@ class FactureFournisseur extends CommonInvoice { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2).$newref, 'files', 1, '^'.preg_quote($oldref,'/')); + $listoffiles=dol_dir_list($conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id,2,0,0, $this, 'invoive_supplier').$newref, 'files', 1, '^'.preg_quote($oldref,'/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 6511bb569e0..35165b33298 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -815,8 +815,8 @@ if (empty($reshook)) $result= $object->generateDocument($object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -1479,7 +1479,7 @@ if ($action=='create') print ''; dol_fiche_head(''); - + print ''; // Ref @@ -1603,7 +1603,7 @@ if ($action=='create') print "
\n"; dol_fiche_end(); - + print '
'; print "\n"; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 73832e9f3b7..bf310d92f8d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -926,143 +926,131 @@ if (empty($reshook)) $result=$object->fetch_thirdparty(); if ($result > 0) { - // $ref = dol_sanitizeFileName($object->ref); - // $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf'; + if ($_POST['sendto']) + { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } + elseif ($_POST['receiver'] != '-1') + { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendtoid = $_POST['receiver']; + } + } - // if (is_readable($file)) - // { - if ($_POST['sendto']) - { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } + if (dol_strlen($sendto)) + { + $langs->load("commercial"); - if (dol_strlen($sendto)) - { - $langs->load("commercial"); + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; + if ($action == 'send') + { + if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; + else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; + $actiontypecode='AC_SUP_INV'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; + if ($message) + { + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + } - if ($action == 'send') - { - if (dol_strlen($_POST['subject'])) $subject=$_POST['subject']; - else $subject = $langs->transnoentities('CustomerOrder').' '.$object->ref; - $actiontypecode='AC_SUP_INV'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($message) - { - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - } + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; + // Send mail + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); + if ($mailfile->error) + { + setEventMessage($mailfile->error,'errors'); + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " + setEventMessage($mesg); - // Send mail - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1); - if ($mailfile->error) - { - setEventMessage($mailfile->error,'errors'); - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain " - setEventMessage($mesg); + $error=0; - $error=0; + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $object->errors=$interface->errors; + } + // Fin appel triggers - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $object->errors=$interface->errors; - } - // Fin appel triggers + if ($error) + { + dol_print_error($db); + } + else + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + setEventMessage($mesg, 'errors'); + } + } + } - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - setEventMessage($mesg, 'errors'); - } - } - } - - else - { - $langs->load("other"); - setEventMessage($langs->trans('ErrorMailRecipientIsEmpty'), 'errors'); - dol_syslog('Recipient email is empty'); - } - /* } - else - { - $langs->load("errors"); - $mesg='
'.$langs->trans('ErrorCantReadFile',$file).'
'; - dol_syslog('Failed to read file: '.$file); - }*/ + else + { + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty'), 'errors'); + dol_syslog('Recipient email is empty'); + } } else { @@ -1095,8 +1083,8 @@ if (empty($reshook)) $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } // Make calculation according to calculationrule @@ -1319,7 +1307,7 @@ if ($action == 'create') } dol_fiche_head(); - + print '
'; print ''; print ''; @@ -1575,7 +1563,7 @@ if ($action == 'create') print "\n"; dol_fiche_end(); - + print '
'; print "
\n"; @@ -2405,8 +2393,8 @@ else */ $ref=dol_sanitizeFileName($object->ref); - $subdir = get_exdir($object->id,2).$ref; - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref; + $subdir = get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; $urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id; $genallowed=$user->rights->fournisseur->facture->creer; $delallowed=$user->rights->fournisseur->facture->supprimer; @@ -2512,7 +2500,7 @@ else { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($ref,'/')); + $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; // Define output language @@ -2539,7 +2527,7 @@ else dol_print_error($db,$result); exit; } - $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($ref,'/')); + $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref, preg_quote($ref,'/')); $file=$fileparams['fullname']; } diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index e6fed653421..7b36ec62c37 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -64,7 +64,7 @@ if ($object->fetch($id, $ref)) { $object->fetch_thirdparty(); $ref=dol_sanitizeFileName($object->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref; + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$ref; } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 887fa7c6fab..010e9b95ae6 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 juanjo Menent * Copyright (C) 2015 Abbes Bahfir - + * 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 * the Free Software Foundation; either version 3 of the License, or @@ -309,7 +309,7 @@ if ($resql) $facturestatic->ref_supplier=$obj->ref_supplier; print $facturestatic->getNomUrl(1); $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid,2).dol_sanitizeFileName($object->ref?$obj->ref:$obj->facid); + $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"; diff --git a/htdocs/fourn/product/photos.php b/htdocs/fourn/product/photos.php index ba5c396c420..49f2fc2b65b 100644 --- a/htdocs/fourn/product/photos.php +++ b/htdocs/fourn/product/photos.php @@ -138,7 +138,7 @@ if ($id) $nbphoto=0; $nbbyrow=5; - $pdir = get_exdir($object->id,2) . $object->id ."/photos/"; + $pdir = get_exdir($object->id,2,0,0,$object,'product') . $object->id ."/photos/"; $dir = $conf->product->multidir_output[$object->entity] . '/'. $pdir; print '
'; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 73e7694c040..1d5ba017aab 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -19,6 +19,10 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +UPDATE llx_facture_fourn set ref=rowid where ref IS NULL; +ALTER TABLE llx_facture_fourn MODIFY COLUMN ref varchar(255) NOT NULL; + + -- IVORY COST (id country=21) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (211, 21, '0','0',0,0,0,0,'IVA Rate 0',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,localtax1,localtax1_type,localtax2,localtax2_type,note,active) values (212, 21, '18','0',7.5,2,0,0,'IVA standard rate',1); @@ -447,6 +451,7 @@ ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country; ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer; ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment; ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_projet integer NULL; +ALTER TABLE llx_don CHANGE COLUMN fk_project fk_projet integer NULL; create table llx_don_extrafields ( diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index 703b86841f9..1e7fa12d565 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -22,7 +22,7 @@ create table llx_facture_fourn ( rowid integer AUTO_INCREMENT PRIMARY KEY, - ref varchar(255), + ref varchar(255) NOT NULL, ref_supplier varchar(255) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4266107d8a3..9a878366bc7 100755 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -170,6 +170,7 @@ ErrorGlobalVariableUpdater4=SOAP client failed with error '%s' ErrorGlobalVariableUpdater5=No global variable selected ErrorFieldMustBeANumeric=Field %s must be a numeric value ErrorFieldMustBeAnInteger=Field %s must be an integer +ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided # Warnings WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index f4f46e263c2..fb087e71800 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -82,7 +82,7 @@ if ($action == 'add') $object->note = $_POST["note"]; $object->commande_id = $_POST["commande_id"]; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - + if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled)) { $expedition->entrepot_id = $_POST["entrepot_id"]; @@ -199,15 +199,12 @@ if ($action == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - $result= $object->generateDocument($object->modelpdf, $outputlangs); - } + $ret=$object->fetch($id); // Reload to get new records + $result= $object->generateDocument($object->modelpdf, $outputlangs); if ($result < 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -589,7 +586,7 @@ else // Incoterms if (!empty($conf->incoterm->enabled)) - { + { print '
'; print '
'; print $langs->trans('IncotermLabel'); @@ -603,7 +600,7 @@ else { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); } - else + else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ebad59202cc..841cea51cd0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -151,13 +151,16 @@ if (! empty($_SERVER["PHP_SELF"])) analyseVarsForSqlAndScriptsInjection($morevaltochecklikepost,2); } // Sanity check on GET parameters -if (! empty($_SERVER["QUERY_STRING"])) +if (! defined('NOSCANGETFORINJECTION') && ! empty($_SERVER["QUERY_STRING"])) { $morevaltochecklikeget=array($_SERVER["QUERY_STRING"]); analyseVarsForSqlAndScriptsInjection($morevaltochecklikeget,1); } // Sanity check on POST -analyseVarsForSqlAndScriptsInjection($_POST,0); +if (! defined('NOSCANPOSTFORINJECTION')) +{ + analyseVarsForSqlAndScriptsInjection($_POST,0); +} // This is to make Dolibarr working with Plesk if (! empty($_SERVER['DOCUMENT_ROOT'])) set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs'); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b2df143e185..d2c3deeb2e4 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -59,12 +59,6 @@ class Product extends CommonObject var $id ; //! Ref var $ref; - /** - * Product label - * @var string - * @deprecated use $label - */ - var $libelle; /** * Product label * @var string @@ -3389,7 +3383,7 @@ class Product extends CommonObject $result = 0; $dir = $sdir; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos"; else $dir .= '/'.dol_sanitizeFileName($this->ref); dol_mkdir($dir); @@ -3427,7 +3421,7 @@ class Product extends CommonObject global $conf; $dir = $sdir; - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos/"; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; else $dir .= '/'.dol_sanitizeFileName($this->ref).'/'; $nbphoto=0; @@ -3474,8 +3468,8 @@ class Product extends CommonObject $pdir = '/'; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $dir .= get_exdir($this->id,2) . $this->id ."/photos/"; - $pdir .= get_exdir($this->id,2) . $this->id ."/photos/"; + $dir .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; + $pdir .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; } else { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index dc4b1f69bdb..60384a29da0 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -274,8 +274,8 @@ if (empty($reshook)) $result= $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } @@ -713,19 +713,6 @@ else if ($action != "edit" ) { - // Validate - if ($object->statut == 0 && $user->rights->projet->creer) - { - if ($userWrite > 0) - { - print ''.$langs->trans("Validate").''; - } - else - { - print ''.$langs->trans('Validate').''; - } - } - // Modify if ($object->statut != 2 && $user->rights->projet->creer) { @@ -739,8 +726,21 @@ else } } + // Validate + if ($object->statut == 0 && $user->rights->projet->creer) + { + if ($userWrite > 0) + { + print ''.$langs->trans("Validate").''; + } + else + { + print ''.$langs->trans('Validate').''; + } + } + // Close - if ($object->statut == 1 && $user->rights->projet->creer) + if (($object->statut == 0 || $object->statut == 1) && $user->rights->projet->creer) { if ($userWrite > 0) { diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index a56de8ec84b..c5f561b2c1c 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -434,8 +434,8 @@ foreach ($listofreferent as $key => $value) } else if($element_doc === 'invoice_supplier') { $element_doc='facture_fournisseur'; - $filename = get_exdir($element->id,2).dol_sanitizeFileName($element->ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($element->id,2).dol_sanitizeFileName($element->ref); + $filename = get_exdir($element->id,2,0,0,$this,'product').dol_sanitizeFileName($element->ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($element->id,2,0,0,null,'invoice_supplier').dol_sanitizeFileName($element->ref); } print $formfile->getDocumentsLink($element_doc, $filename, $filedir); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8dd7bac68d8..5d8085efcdd 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -162,8 +162,8 @@ if ($action == 'builddoc' && $user->rights->projet->creer) $result= $object->generateDocument($object->modelpdf, $outputlangs); if ($result <= 0) { - dol_print_error($db,$result); - exit; + setEventMessages($object->error, $object->errors, 'errors'); + $action=''; } } diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index f3c217d0a54..b152e6097c6 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -65,7 +65,7 @@ if ($id > 0 || ! empty($ref)) $result = $object->fetch($id, $ref); $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; - $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id); + $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id,0,0,0,$object,'thirdparty'); } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 332684a3238..3a561ce8ebb 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -438,15 +438,15 @@ if ($action == 'update' && ! $_POST["cancel"]) { if (GETPOST('deletephoto') && $object->photo) { - $fileimg=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1).'/logos/'.$object->photo; - $dirthumbs=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1).'/logos/thumbs'; + $fileimg=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'user').'/logos/'.$object->photo; + $dirthumbs=$conf->user->dir_output.'/'.get_exdir($object->id,2,0,1,$object,'user').'/logos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir= $conf->user->dir_output . '/' . get_exdir($object->id,2,0,1); + $dir= $conf->user->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'user'); dol_mkdir($dir); diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 345679f7c9a..2bf914ebd38 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -124,7 +124,7 @@ $server->wsdl->addComplexType( ) ) ); - + /* * An image */ @@ -217,7 +217,7 @@ function getCategory($authentication,$id) if ($result > 0) { $dir = (!empty($conf->categorie->dir_output)?$conf->categorie->dir_output:$conf->service->dir_output); - $pdir = get_exdir($categorie->id,2) . $categorie->id ."/photos/"; + $pdir = get_exdir($categorie->id,2,0,0,$categorie,'category') . $categorie->id ."/photos/"; $dir = $dir . '/'. $pdir; $cat = array( @@ -238,7 +238,7 @@ function getCategory($authentication,$id) foreach($cats as $fille) { $dir = (!empty($conf->categorie->dir_output)?$conf->categorie->dir_output:$conf->service->dir_output); - $pdir = get_exdir($fille->id,2) . $fille->id ."/photos/"; + $pdir = get_exdir($fille->id,2,0,0,$categorie,'category') . $fille->id ."/photos/"; $dir = $dir . '/'. $pdir; $cat['filles'][] = array( 'id'=>$fille->id, diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index b7af224ff52..86891e87595 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2) . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; @@ -1055,7 +1055,7 @@ function getProductsForCategory($authentication,$id,$lang='') if($obj->status > 0 ) { $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($obj->id,2) . $obj->id ."/photos/"; + $pdir = get_exdir($obj->id,2,0,0,$product,'product') . $obj->id ."/photos/"; $dir = $dir . '/'. $pdir; $products[] = array(