diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5a4db149b87..779a7da96f5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -448,11 +448,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; $msg.= $langs->transnoentities('ErrorCodeCantContainZero').'
'; } - if (!is_numeric($_POST['code'])) + // FIXME regresion if code with not in numeric base + /*if (!is_numeric($_POST['code'])) { $ok = 0; $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; - } + }*/ } if (isset($_POST["pays"]) && $_POST["pays"]=='0') { $ok=0; diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 9fcbca3e743..6a576c580ca 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -51,6 +51,19 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } +$act = new ActionComm($db); + +if ($objectid > 0) +{ + $ret = $act->fetch($objectid); + if ($ret > 0) { + $company=new Societe($db); + $company->fetch($act->societe->id); + $act->societe=$company; // For backward compatibility + $act->thirdparty=$company; + } +} + // Get parameters $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -79,7 +92,7 @@ if ($action == 'delete') { $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file); + $ret=dol_delete_file($file,0,0,0,$act); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); $action=''; @@ -96,184 +109,172 @@ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); -if ($objectid > 0) +if ($act->id > 0) { - $act = new ActionComm($db); - if ($act->fetch($objectid)) + $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); + + $author=new User($db); + $author->fetch($act->author->id); + $act->author=$author; + + if ($act->contact->id) $act->fetch_contact($act->contact->id); + + $head=actions_prepare_head($act); + dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action'); + + // Affichage fiche action en mode visu + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Type + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); + print ''; + } - $company=new Societe($db); - $company->fetch($act->societe->id); - $act->societe=$company; + // Title + print ''; - $author=new User($db); - $author->fetch($act->author->id); - $act->author=$author; + // Full day event + print ''; - if ($act->contact->id) $act->fetch_contact($act->contact->id); + // Date start + print ''; + print ''; + print ''; - $head=actions_prepare_head($act); - dol_fiche_head($head, 'documents', $langs->trans("Action"),0,'action'); + // Date end + print ''; - // Affichage fiche action en mode visu - print '
'.$langs->trans("Ref").''; + print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); + print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Title").''.$act->label.'
'.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent).'
'.$langs->trans("DateActionStart").''; + if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour'); + else print dol_print_date($act->datep,'day'); + if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); + print ''."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendar').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarweek').' '; + print '
'."\n"; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print img_picto($langs->trans("ViewCal"),'object_calendarday').' '; + print '
'."\n"; + print '
'.$langs->trans("DateActionEnd").''; + if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour'); + else print dol_print_date($act->datef,'day'); + if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); + print '
'; + // Status + print ''; - $linkback = ''.$langs->trans("BackToList").''; + // Location + print ''; - // Ref - print ''; - // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + print $act->getLibStatut(4); + print '
'.$langs->trans("Location").''.$act->location.'
'.$langs->trans("Ref").''; - print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); - print '


'; + + + // Third party - Contact + print ''; + print "
".dol_print_phone($act->societe->tel); } - - // Title - print ''; - - // Full day event - print ''; - - // Date start - print ''; - print ''; - print ''; - - // Date end - print ''; - - // Status - print ''; - - // Location - print ''; - - - print '
'.$langs->trans("ActionOnCompany").''.($act->societe->id?$act->societe->getNomUrl(1):$langs->trans("None")); + if ($act->societe->id && $act->type_code == 'AC_TEL') + { + if ($act->societe->fetch($act->societe->id)) { - print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Title").''.$act->label.'
'.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent).'
'.$langs->trans("DateActionStart").''; - if (! $act->fulldayevent) print dol_print_date($act->datep,'dayhour'); - else print dol_print_date($act->datep,'day'); - if ($act->percentage == 0 && $act->datep && $act->datep < ($now - $delay_warning)) print img_warning($langs->trans("Late")); - print ''."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendar').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarweek').' '; - print '
'."\n"; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - //print ''; - print img_picto($langs->trans("ViewCal"),'object_calendarday').' '; - print '
'."\n"; - print '
'.$langs->trans("DateActionEnd").''; - if (! $act->fulldayevent) print dol_print_date($act->datef,'dayhour'); - else print dol_print_date($act->datef,'day'); - if ($act->percentage > 0 && $act->percentage < 100 && $act->datef && $act->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); - print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - print $act->getLibStatut(4); - print '
'.$langs->trans("Location").''.$act->location.'


'; - - - // Third party - Contact - print ''; - print ''; - print ''; - - // Project - if (! empty($conf->projet->enabled)) - { - print ''; - } - - // Priority - print ''; - - - print '
'.$langs->trans("ActionOnCompany").''.($act->societe->id?$act->societe->getNomUrl(1):$langs->trans("None")); - if ($act->societe->id && $act->type_code == 'AC_TEL') - { - if ($act->societe->fetch($act->societe->id)) - { - print "
".dol_print_phone($act->societe->tel); - } - } - print '
'.$langs->trans("Contact").''; - if ($act->contact->id > 0) - { - print $act->contact->getNomUrl(1); - if ($act->contact->id && $act->type_code == 'AC_TEL') - { - if ($act->contact->fetch($act->contact->id)) - { - print "
".dol_print_phone($act->contact->phone_pro); - } - } - } - else - { - print $langs->trans("None"); - } - - print '
'.$langs->trans("Project").''; - if ($act->fk_project) - { - $project=new Project($db); - $project->fetch($act->fk_project); - print $project->getNomUrl(1); - } - print '
'.$langs->trans("Priority").''; - print ($act->priority?$act->priority:''); - print '


'; - - // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $totalsize=0; - foreach($filearray as $key => $file) + } + print ''; + print ''; + print ''; - print ''; - print '
'.$langs->trans("Contact").''; + if ($act->contact->id > 0) + { + print $act->contact->getNomUrl(1); + if ($act->contact->id && $act->type_code == 'AC_TEL') { - $totalsize+=$file['size']; + if ($act->contact->fetch($act->contact->id)) + { + print "
".dol_print_phone($act->contact->phone_pro); + } } - - - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print ''; - - - // Affiche formulaire upload - $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)); - - - // List of document - $param='&id='.$act->id; - $formfile->list_of_documents($filearray,$act,'actions',$param,0,'',$user->rights->agenda->myactions->create); } else { - dol_print_error($db); + print $langs->trans("None"); } + + print ''; + + // Project + if (! empty($conf->projet->enabled)) + { + print ''.$langs->trans("Project").''; + if ($act->fk_project) + { + $project=new Project($db); + $project->fetch($act->fk_project); + print $project->getNomUrl(1); + } + print ''; + } + + // Priority + print ''.$langs->trans("Priority").''; + print ($act->priority?$act->priority:''); + print ''; + + + print '

'; + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + print ''; + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create),50,$act); + + + // List of document + $param='&id='.$act->id; + $formfile->list_of_documents($filearray,$act,'actions',$param,0,'',$user->rights->agenda->myactions->create); } else { diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 6fbd0a23143..f62b2fcc594 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class ChargeSociales extends CommonObject { - public $element='rowid'; + public $element='chargesociales'; public $table='chargesociales'; public $table_element='chargesociales'; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index dcb082b41d7..452de21285a 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -79,7 +79,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($action == 'delete') { $file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($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'); } @@ -172,7 +172,7 @@ if ($object->id) // Affiche formulaire upload $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id,'',0,0,$user->rights->tax->charges->creer); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id,'',0,0,$user->rights->tax->charges->creer,50,$object); // List of document diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index c5e83017940..910ad55e0a0 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -56,6 +56,8 @@ class FileUpload $filename = $regs[2]; } + $parentForeignKey = ''; + // For compatibility if ($element == 'propal') { $pathname = 'comm/propal'; @@ -69,6 +71,14 @@ class FileUpload $element = $pathname = 'projet'; $dir_output=$conf->$element->dir_output; } + elseif ($element == 'project_task') { + $pathname = 'projet'; $filename='task'; + $dir_output=$conf->projet->dir_output; + $parentForeignKey = 'fk_project'; + $parentClass = 'Project'; + $parentElement = 'projet'; + $parentObject = 'project'; + } elseif ($element == 'fichinter') { $element='ficheinter'; $dir_output=$conf->$element->dir_output; @@ -80,6 +90,17 @@ class FileUpload elseif ($element == 'invoice_supplier') { $pathname = 'fourn'; $filename='fournisseur.facture'; $dir_output=$conf->fournisseur->facture->dir_output; + } + elseif ($element == 'product') { + $dir_output = $conf->product->multidir_output[$conf->entity]; + } + elseif ($element == 'action') { + $pathname = 'comm/action'; $filename='actioncomm'; + $dir_output=$conf->agenda->dir_output; + } + elseif ($element == 'chargesociales') { + $pathname = 'compta/sociales'; $filename='chargesociales'; + $dir_output=$conf->tax->dir_output; } else { $dir_output=$conf->$element->dir_output; } @@ -97,11 +118,23 @@ class FileUpload $object = new $classname($db); $object->fetch($fk_element); - $object->fetch_thirdparty(); + if (!empty($parentForeignKey)) { + dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php'); + $parent = new $parentClass($db); + $parent->fetch($object->$parentForeignKey); + if (!empty($parent->socid)) { + $parent->fetch_thirdparty(); + } + $object->$parentObject = dol_clone($parent); + } else { + $object->fetch_thirdparty(); + } $object_ref = dol_sanitizeFileName($object->ref); if ($element == 'invoice_supplier') { $object_ref = get_exdir($object->id, 2) . $object_ref; + } else if ($element == 'project_task') { + $object_ref = $object->project->ref . '/' . $object_ref; } $this->options = array( diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index f28e5d27e6d..12571aad64a 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -171,6 +171,7 @@ class Task extends CommonObject $sql.= " t.label,"; $sql.= " t.description,"; $sql.= " t.duration_effective,"; + $sql.= " t.datec,"; $sql.= " t.dateo,"; $sql.= " t.datee,"; $sql.= " t.fk_user_creat,"; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 5d42a44d54b..90adc2925c2 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -93,7 +93,11 @@ if ($id > 0 || ! empty($ref)) { $projectstatic->fetch($object->fk_project); - if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); + if (! empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $object->project = dol_clone($projectstatic); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); } @@ -114,7 +118,7 @@ if ($action=='delete') { $langs->load("other"); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($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'); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);