Several fix for a better management of #6424

This commit is contained in:
Laurent Destailleur 2017-02-22 17:46:54 +01:00
parent 24c2675705
commit 92d9eb3c5d
11 changed files with 268 additions and 183 deletions

View File

@ -146,6 +146,14 @@ if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
$listUserAssignedUpdated = true; $listUserAssignedUpdated = true;
} }
// Link to a project
if ($action == 'classin' && ($user->rights->agenda->allactions->create ||
(($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)))
{
$object->fetch($id);
$object->setProject(GETPOST('projectid'));
}
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
@ -577,6 +585,8 @@ if ($action == 'mupdate')
* View * View
*/ */
$formproject=new FormProjets($db);
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; $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);
@ -744,7 +754,7 @@ if ($action == 'create')
print '<br><br>'; print '<br><br>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Societe, contact // Related company
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>'; print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>';
if (GETPOST('socid','int') > 0) if (GETPOST('socid','int') > 0)
{ {
@ -755,7 +765,6 @@ if ($action == 'create')
} }
else else
{ {
$events=array(); $events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
//For external user force the company to user company //For external user force the company to user company
@ -768,6 +777,7 @@ if ($action == 'create')
} }
print '</td></tr>'; print '</td></tr>';
// Related contact
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>'; print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
$form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200'); $form->select_contacts(GETPOST('socid','int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
print '</td></tr>'; print '</td></tr>';
@ -1090,10 +1100,10 @@ if ($id > 0)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Thirdparty - Contact
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>'; // Related company
print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
print '<td>'; print '<td>';
print '<div class="maxwidth200onsmartphone">'; print '<div class="maxwidth200onsmartphone">';
$events=array(); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts $events=array(); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts
@ -1104,8 +1114,8 @@ if ($id > 0)
print '</div>'; print '</div>';
print '</td></tr>'; print '</td></tr>';
// Contact // related contact
print '<tr><td>'.$langs->trans("Contact").'</td><td>'; print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
print '<div class="maxwidth200onsmartphone">'; print '<div class="maxwidth200onsmartphone">';
$form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200'); $form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200');
print '</div>'; print '</div>';
@ -1199,27 +1209,61 @@ if ($id > 0)
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>'; $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
$linkback.=$out; $linkback.=$out;
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
$morehtmlref='<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref.=$langs->trans('Project') . ' ';
if ($user->rights->agenda->allactions->create ||
(($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
if ($proj->title) $morehtmlref.=' - '.$proj->title;
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
// Affichage fiche action en mode visu // Affichage fiche action en mode visu
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
/*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
print '</td></tr>';*/
// Type // Type
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
} }
// Title
//print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.dol_htmlentities($object->label).'</td></tr>';
// Full day event // Full day event
print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
@ -1241,11 +1285,6 @@ if ($id > 0)
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>'; print '</td></tr>';
// Status
/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
print $object->getLibStatut(4);
print '</td></tr>';*/
// Location // Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{ {
@ -1302,14 +1341,14 @@ if ($id > 0)
print '</table>'; print '</table>';
print '<br><br>'; print '<br>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Third party - Contact
if ($conf->societe->enabled) if ($conf->societe->enabled)
{ {
print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None")); // Related company
print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td colspan="3">'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):('<span class="opacitymedium">'.$langs->trans("None").'</span>'));
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
{ {
if ($object->thirdparty->fetch($object->thirdparty->id)) if ($object->thirdparty->fetch($object->thirdparty->id))
@ -1317,9 +1356,11 @@ if ($id > 0)
print "<br>".dol_print_phone($object->thirdparty->phone); print "<br>".dol_print_phone($object->thirdparty->phone);
} }
} }
print '</td>'; print '</td></tr>';
print '<td>'.$langs->trans("Contact").'</td>';
print '<td>'; // Related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td>';
print '<td colspan="3">';
if ($object->contactid > 0) if ($object->contactid > 0)
{ {
print $object->contact->getNomUrl(1); print $object->contact->getNomUrl(1);
@ -1333,12 +1374,13 @@ if ($id > 0)
} }
else else
{ {
print $langs->trans("None"); print '<span class="opacitymedium">'.$langs->trans("NoneOrSeveral").'</span>';
} }
print '</td></tr>'; print '</td></tr>';
} }
// Project // Project
/*
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
@ -1350,6 +1392,7 @@ if ($id > 0)
} }
print '</td></tr>'; print '</td></tr>';
} }
*/
// Priority // Priority
print '<tr><td class="nowrap" class="titlefield">'.$langs->trans("Priority").'</td><td colspan="3">'; print '<tr><td class="nowrap" class="titlefield">'.$langs->trans("Priority").'</td><td colspan="3">';

View File

@ -140,27 +140,41 @@ if ($object->id > 0)
$linkback.=$out; $linkback.=$out;
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); $morehtmlref='<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref.=$langs->trans('Project') . ': ';
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
if ($proj->title) $morehtmlref.=' - '.$proj->title;
} else {
$morehtmlref.='';
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
// Affichage fiche action en mode visu // Affichage fiche action en mode visu
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref
/*print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
print '</td></tr>';*/
// Type // Type
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
} }
// Title
//print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Full day event // Full day event
print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent, 3).'</td></tr>';
@ -179,11 +193,6 @@ if ($object->id > 0)
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late"));
print '</td></tr>'; print '</td></tr>';
// Status
/*print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="2">';
print $object->getLibStatut(4);
print '</td></tr>';*/
// Location // Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{ {
@ -227,71 +236,8 @@ if ($object->id > 0)
print '</table>'; print '</table>';
print '<br><br>';
print '<table class="border" width="100%">'; print '<br>';
// Third party - Contact
print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None"));
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL')
{
if ($object->thirdparty->fetch($object->thirdparty->id))
{
print "<br>".dol_print_phone($object->thirdparty->phone);
}
}
print '</td>';
print '<td>'.$langs->trans("Contact").'</td>';
print '<td>';
if ($object->contact->id > 0)
{
print $object->contact->getNomUrl(1);
if ($object->contact->id && $object->type_code == 'AC_TEL')
{
if ($object->contact->fetch($object->contact->id))
{
print "<br>".dol_print_phone($object->contact->phone_pro);
}
}
}
else
{
print $langs->trans("None");
}
print '</td></tr>';
// Project
if (! empty($conf->projet->enabled))
{
print '<tr><td class="tdtop">'.$langs->trans("Project").'</td><td colspan="3">';
if ($object->fk_project)
{
$project=new Project($db);
$project->fetch($object->fk_project);
print $project->getNomUrl(1);
}
print '</td></tr>';
}
// Priority
print '<tr><td class="nowrap">'.$langs->trans("Priority").'</td><td colspan="3">';
print ($object->priority?$object->priority:'');
print '</td></tr>';
// Other attributes
$parameters=array('colspan'=>' colspan="3"', 'colspanvalue'=>'3', 'id'=>$object->id);
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>';
print '<br><br>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -28,6 +28,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
$langs->load("commercial"); $langs->load("commercial");
@ -74,7 +78,29 @@ $out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.do
$linkback.=$out; $linkback.=$out;
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); $morehtmlref='<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref.=$langs->trans('Project') . ': ';
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
if ($proj->title) $morehtmlref.=' - '.$proj->title;
} else {
$morehtmlref.='';
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';

View File

@ -112,7 +112,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{ {
$result=$object->fetch($id); $result=$object->fetch($id);
$sendtosocid=0; $sendtosocid=0; // Thirdparty on object
if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe') if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
{ {
$result=$object->fetch_thirdparty(); $result=$object->fetch_thirdparty();
@ -123,7 +123,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{ {
$thirdparty=$object; $thirdparty=$object;
if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id;
elseif($conf->dolimail->enabled) elseif (! empty($conf->dolimail->enabled))
{ {
$dolimail = new Dolimail($db); $dolimail = new Dolimail($db);
$possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1");
@ -160,51 +160,71 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($result > 0) if ($result > 0)
{ {
$receiver=$_POST['receiver']; $sendto='';
$sendto_array=array(); $sendtocc='';
$sendtobcc='';
$sendtoid = array();
// Define $sendto
$receiver=$_POST['receiver'];
if (! is_array($receiver))
{
if ($receiver == '-1') $receiver=array();
else $receiver=array($receiver);
}
$tmparray=array();
if (trim($_POST['sendto'])) if (trim($_POST['sendto']))
{ {
// Recipient is provided into free text // Recipients are provided into free text
$sendto = trim($_POST['sendto']); $tmparray[] = trim($_POST['sendto']);
$sendtoid = array();
} }
elseif (count($receiver)>0) if (count($receiver)>0)
{ {
foreach($receiver as $key=>$val) { foreach($receiver as $key=>$val)
{
// Recipient was provided from combo list // Recipient was provided from combo list
if ($val == 'thirdparty') // Id of third party if ($val == 'thirdparty') // Id of third party
{ {
$sendto_array[] = $thirdparty->name.' <'.$thirdparty->email.'>'; $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
$sendtoid = array();
} }
else // Id du contact else // Id du contact
{ {
$sendto_array[] = $thirdparty->contact_get_property((int) $val,'email'); $tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
$sendtoid[] = $val; $sendtoid[] = $val;
} }
} }
if (count($sendto_array)>0) {
$sendto=implode(',',$sendto_array);
}
} }
$sendto=implode(',',$tmparray);
// Define $sendtocc
$receivercc=$_POST['receivercc'];
if (! is_array($receivercc))
{
if ($receivercc == '-1') $receivercc=array();
else $receivercc=array($receivercc);
}
$tmparray=array();
if (trim($_POST['sendtocc'])) if (trim($_POST['sendtocc']))
{ {
$sendtocc = trim($_POST['sendtocc']); $tmparray[] = trim($_POST['sendtocc']);
} }
elseif ($_POST['receivercc'] != '-1') if (count($receivercc) > 0)
{ {
// Recipient was provided from combo list foreach($receivercc as $key=>$val)
if ($_POST['receivercc'] == 'thirdparty') // Id of third party
{ {
$sendtocc = $thirdparty->name.' <'.$thirdparty->email.'>'; // Recipient was provided from combo list
} if ($val == 'thirdparty') // Id of third party
else // Id du contact {
{ $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
$sendtocc = $thirdparty->contact_get_property((int) $_POST['receivercc'],'email'); }
else // Id du contact
{
$tmparray[] = $thirdparty->contact_get_property((int) $val,'email');
//$sendtoid[] = $val; TODO Add also id of contact in CC ?
}
} }
} }
$sendtocc=implode(',',$tmparray);
if (dol_strlen($sendto)) if (dol_strlen($sendto))
{ {
@ -233,6 +253,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
$message = $_POST['message']; $message = $_POST['message'];
$sendtobcc= GETPOST('sendtoccc'); $sendtobcc= GETPOST('sendtoccc');
if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO)); if ($mode == 'emailfromproposal') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO)); if ($mode == 'emailfromorder') $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc?", ":"").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
@ -348,46 +369,22 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Initialisation of datas // Initialisation of datas
if (is_object($object)) if (is_object($object))
{ {
//multiple contact sends $object->socid = $sendtosocid; // To link to a company
if (count($sendtoid) >0) { $object->sendtoid = $sendtoid; // To link to contacts/addresses. This is an array.
foreach($sendtoid as $val_id) { $object->actiontypecode = $actiontypecode;
$object->socid = $sendtosocid; // To link to a company $object->actionmsg = $actionmsg; // Long text
$object->sendtoid = $val_id; // To link to a contact/address $object->actionmsg2 = $actionmsg2; // Short text
$object->actiontypecode = $actiontypecode; $object->trackid = $trackid;
$object->actionmsg = $actionmsg; // Long text $object->fk_element = $object->id;
$object->actionmsg2 = $actionmsg2; // Short text $object->elementtype = $object->element;
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
// Call of triggers // Call of triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf); $result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $errors=$interface->errors; $error++; $errors=$interface->errors;
} }
}
} else {
//Thirdparty send
$object->socid = $sendtosocid; // To link to a company
$object->sendtoid = 0; // To link to a contact/address
$object->actiontypecode = $actiontypecode;
$object->actionmsg = $actionmsg; // Long text
$object->actionmsg2 = $actionmsg2; // Short text
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
// Call of triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers($trigger_name,$object,$user,$langs,$conf);
if ($result < 0) {
$error++; $errors=$interface->errors;
}
}
// End call of triggers
} }
if ($error) if ($error)

View File

@ -1395,9 +1395,18 @@ abstract class CommonObject
} }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
if ($projectid) $sql.= ' SET fk_projet = '.$projectid; if ($this->table_element == 'actioncomm')
else $sql.= ' SET fk_projet = NULL'; {
$sql.= ' WHERE rowid = '.$this->id; if ($projectid) $sql.= ' SET fk_project = '.$projectid;
else $sql.= ' SET fk_project = NULL';
$sql.= ' WHERE id = '.$this->id;
}
else
{
if ($projectid) $sql.= ' SET fk_projet = '.$projectid;
else $sql.= ' SET fk_projet = NULL';
$sql.= ' WHERE rowid = '.$this->id;
}
dol_syslog(get_class($this)."::setProject", LOG_DEBUG); dol_syslog(get_class($this)."::setProject", LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))

View File

@ -521,10 +521,17 @@ class FormMail extends Form
if (! empty($this->withto) && is_array($this->withto)) if (! empty($this->withto) && is_array($this->withto))
{ {
if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." "; if (! empty($this->withtofree)) $out.= " ".$langs->trans("or")." ";
$out.= $form->multiselectarray("receiver", $this->withto, GETPOST("receiver"), null, null, null,null, "90%"); // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withto;
foreach($tmparray as $key => $val)
{
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$out.= $form->multiselectarray("receiver", $tmparray, GETPOST("receiver"), null, null, null,null, "90%");
} }
if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method. if (isset($this->withtosocid) && $this->withtosocid > 0) // deprecated. TODO Remove this. Instead, fill withto with array before calling method.
{ {
dol_syslog("get_form was called with a deprecated way: ->withtosocid must not be defined, only ->withto", LOG_WARNING);
$liste=array(); $liste=array();
$soc=new Societe($this->db); $soc=new Societe($this->db);
$soc->fetch($this->withtosocid); $soc->fetch($this->withtosocid);
@ -533,6 +540,12 @@ class FormMail extends Form
$liste[$key]=$value; $liste[$key]=$value;
} }
if ($this->withtofree) $out.= " ".$langs->trans("or")." "; if ($this->withtofree) $out.= " ".$langs->trans("or")." ";
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $liste;
foreach($tmparray as $key => $val)
{
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
$out.= $form->multiselectarray("receiver", $liste, GETPOST("receiver"), null, null, null,null, "90%"); $out.= $form->multiselectarray("receiver", $liste, GETPOST("receiver"), null, null, null,null, "90%");
} }
} }
@ -555,7 +568,14 @@ class FormMail extends Form
if (! empty($this->withtocc) && is_array($this->withtocc)) if (! empty($this->withtocc) && is_array($this->withtocc))
{ {
$out.= " ".$langs->trans("or")." "; $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails); // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withtocc;
foreach($tmparray as $key => $val)
{
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
//$out.= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1, 0, 0, '', 0, 0, 0, '', '', 0, '', $disablebademails);
$out.= $form->multiselectarray("receivercc", $tmparray, GETPOST("receivercc"), null, null, null,null, "90%");
} }
} }
$out.= "</td></tr>\n"; $out.= "</td></tr>\n";
@ -577,7 +597,14 @@ class FormMail extends Form
if (! empty($this->withtoccc) && is_array($this->withtoccc)) if (! empty($this->withtoccc) && is_array($this->withtoccc))
{ {
$out.= " ".$langs->trans("or")." "; $out.= " ".$langs->trans("or")." ";
$out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
$tmparray = $this->withtoccc;
foreach($tmparray as $key => $val)
{
$tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true);
}
//$out.= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1);
$out.= $form->multiselectarray("receiverccc", $tmparray, GETPOST("receiverccc"), null, null, null,null, "90%");
} }
} }

View File

@ -47,7 +47,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
* $object->actiontypecode (translation action code: AC_OTH, ...) * $object->actiontypecode (translation action code: AC_OTH, ...)
* $object->actionmsg (note, long text) * $object->actionmsg (note, long text)
* $object->actionmsg2 (label, short text) * $object->actionmsg2 (label, short text)
* $object->sendtoid (id of contact) * $object->sendtoid (id of contact or array of ids)
* $object->socid * $object->socid
* $object->fk_project * $object->fk_project
* $object->fk_element * $object->fk_element
@ -819,7 +819,16 @@ class InterfaceActionsAuto extends DolibarrTriggers
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$contactforaction=new Contact($this->db); $contactforaction=new Contact($this->db);
$societeforaction=new Societe($this->db); $societeforaction=new Societe($this->db);
if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); // Set contactforaction if there is only 1 contact.
if (is_array($object->sendtoid))
{
if (count($object->sendtoid) == 1) $contactforaction->fetch(reset($object->sendtoid));
}
else
{
if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid);
}
// Set societeforaction.
if ($object->socid > 0) $societeforaction->fetch($object->socid); if ($object->socid > 0) $societeforaction->fetch($object->socid);
// Insertion action // Insertion action

View File

@ -453,6 +453,7 @@ NextStep=Next step
Datas=Data Datas=Data
None=None None=None
NoneF=None NoneF=None
NoneOrSeveral=None or several
Late=Late Late=Late
LateDesc=Delay to define if a record is late or not depends on your setup. Ask your admin to change delay from menu Home - Setup - Alerts. LateDesc=Delay to define if a record is late or not depends on your setup. Ask your admin to change delay from menu Home - Setup - Alerts.
Photo=Picture Photo=Picture

View File

@ -31,6 +31,10 @@ if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (! empty($conf->projet->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
// Load traductions files requiredby by page // Load traductions files requiredby by page
$langs->load("resource"); $langs->load("resource");
@ -212,7 +216,29 @@ else
$linkback.=$out; $linkback.=$out;
dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '', '&element='.$element, 0, '', ''); $morehtmlref='<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
//$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
$morehtmlref.=$langs->trans('Project') . ': ';
if (! empty($act->fk_project)) {
$proj = new Project($db);
$proj->fetch($act->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $act->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
if ($proj->title) $morehtmlref.=' - '.$proj->title;
} else {
$morehtmlref.='';
}
}
$morehtmlref.='</div>';
dol_banner_tab($act, 'element_id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref, '&element='.$element, 0, '', '');
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';

View File

@ -2026,8 +2026,9 @@ class Societe extends CommonObject
if ($this->email && $addthirdparty) if ($this->email && $addthirdparty)
{ {
if (empty($this->name)) $this->name=$this->nom; if (empty($this->name)) $this->name=$this->nom;
$contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." (".$this->email.")"; $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." &lt;".$this->email."&gt;";
} }
//var_dump($contact_emails)
return $contact_emails; return $contact_emails;
} }

View File

@ -2447,7 +2447,7 @@ else
$liste=array(); $liste=array();
foreach ($object->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; foreach ($object->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value;
$formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste;
$formmail->withtofree=0; $formmail->withtofree=1;
$formmail->withtocc=$liste; $formmail->withtocc=$liste;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withfile=2; $formmail->withfile=2;