Merge branch '3.3' of git@github.com:Dolibarr/dolibarr.git into 3.3

This commit is contained in:
Laurent Destailleur 2013-04-22 20:37:28 +02:00
commit 83e873dd24
7 changed files with 209 additions and 169 deletions

View File

@ -448,11 +448,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$ok=0; $ok=0;
$msg.= $langs->transnoentities('ErrorCodeCantContainZero').'<br>'; $msg.= $langs->transnoentities('ErrorCodeCantContainZero').'<br>';
} }
if (!is_numeric($_POST['code'])) // FIXME regresion if code with not in numeric base
/*if (!is_numeric($_POST['code']))
{ {
$ok = 0; $ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br />'; $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br />';
} }*/
} }
if (isset($_POST["pays"]) && $_POST["pays"]=='0') { if (isset($_POST["pays"]) && $_POST["pays"]=='0') {
$ok=0; $ok=0;

View File

@ -51,6 +51,19 @@ if ($user->societe_id > 0)
$socid = $user->societe_id; $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 // Get parameters
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
@ -79,7 +92,7 @@ if ($action == 'delete')
{ {
$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); $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). $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'))); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$action=''; $action='';
@ -96,17 +109,10 @@ $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
llxHeader('',$langs->trans("Agenda"),$help_url); 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); $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid);
$company=new Societe($db);
$company->fetch($act->societe->id);
$act->societe=$company;
$author=new User($db); $author=new User($db);
$author->fetch($act->author->id); $author->fetch($act->author->id);
$act->author=$author; $act->author=$author;
@ -263,17 +269,12 @@ if ($objectid > 0)
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $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)); $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 // List of document
$param='&id='.$act->id; $param='&id='.$act->id;
$formfile->list_of_documents($filearray,$act,'actions',$param,0,'',$user->rights->agenda->myactions->create); $formfile->list_of_documents($filearray,$act,'actions',$param,0,'',$user->rights->agenda->myactions->create);
}
else
{
dol_print_error($db);
}
} }
else else
{ {

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/ */
class ChargeSociales extends CommonObject class ChargeSociales extends CommonObject
{ {
public $element='rowid'; public $element='chargesociales';
public $table='chargesociales'; public $table='chargesociales';
public $table_element='chargesociales'; public $table_element='chargesociales';

View File

@ -79,7 +79,7 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
if ($action == 'delete') if ($action == 'delete')
{ {
$file = $upload_dir . '/' . GETPOST("urlfile"); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $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'))); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
} }
@ -172,7 +172,7 @@ if ($object->id)
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $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 // List of document

View File

@ -56,6 +56,8 @@ class FileUpload
$filename = $regs[2]; $filename = $regs[2];
} }
$parentForeignKey = '';
// For compatibility // For compatibility
if ($element == 'propal') { if ($element == 'propal') {
$pathname = 'comm/propal'; $pathname = 'comm/propal';
@ -69,6 +71,14 @@ class FileUpload
$element = $pathname = 'projet'; $element = $pathname = 'projet';
$dir_output=$conf->$element->dir_output; $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') { elseif ($element == 'fichinter') {
$element='ficheinter'; $element='ficheinter';
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
@ -80,6 +90,17 @@ class FileUpload
elseif ($element == 'invoice_supplier') { elseif ($element == 'invoice_supplier') {
$pathname = 'fourn'; $filename='fournisseur.facture'; $pathname = 'fourn'; $filename='fournisseur.facture';
$dir_output=$conf->fournisseur->facture->dir_output; $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 { } else {
$dir_output=$conf->$element->dir_output; $dir_output=$conf->$element->dir_output;
} }
@ -97,11 +118,23 @@ class FileUpload
$object = new $classname($db); $object = new $classname($db);
$object->fetch($fk_element); $object->fetch($fk_element);
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->fetch_thirdparty();
}
$object_ref = dol_sanitizeFileName($object->ref); $object_ref = dol_sanitizeFileName($object->ref);
if ($element == 'invoice_supplier') { if ($element == 'invoice_supplier') {
$object_ref = get_exdir($object->id, 2) . $object_ref; $object_ref = get_exdir($object->id, 2) . $object_ref;
} else if ($element == 'project_task') {
$object_ref = $object->project->ref . '/' . $object_ref;
} }
$this->options = array( $this->options = array(

View File

@ -171,6 +171,7 @@ class Task extends CommonObject
$sql.= " t.label,"; $sql.= " t.label,";
$sql.= " t.description,"; $sql.= " t.description,";
$sql.= " t.duration_effective,"; $sql.= " t.duration_effective,";
$sql.= " t.datec,";
$sql.= " t.dateo,"; $sql.= " t.dateo,";
$sql.= " t.datee,"; $sql.= " t.datee,";
$sql.= " t.fk_user_creat,"; $sql.= " t.fk_user_creat,";

View File

@ -93,7 +93,11 @@ if ($id > 0 || ! empty($ref))
{ {
$projectstatic->fetch($object->fk_project); $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); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref);
} }
@ -114,7 +118,7 @@ if ($action=='delete')
{ {
$langs->load("other"); $langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $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'))); if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);