diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php index 3020799c91e..0d39ebb13ed 100644 --- a/htdocs/public/bookcal/booking.php +++ b/htdocs/public/bookcal/booking.php @@ -60,6 +60,22 @@ require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.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/actioncommreminder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Init vars $errmsg = ''; @@ -75,9 +91,15 @@ $langs->loadLangs(array("main", "members", "companies", "install", "other")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('publicnewpartnershipcard', 'globalcard')); + +$object = new ActionComm($db); +$cactioncomm = new CActionComm($db); +$contact = new Contact($db); +$formfile = new FormFile($db); +$formactions = new FormActions($db); $extrafields = new ExtraFields($db); -$object = new Partnership($db); + $user->loadDefaultValues(); @@ -153,7 +175,6 @@ function llxFooterVierge() } - /* * Actions */ @@ -196,27 +217,27 @@ if (empty($reshook) && $action == 'add') { if (!$error) { //$partnership = new Partnership($db); - $event = new Event($db); + $events = new Events($db); // We try to find the thirdparty or the member if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') { - $partnership->fk_member = 0; + $event->fk_member = 0; } elseif (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') { - $partnership->fk_soc = 0; + $event->fk_soc = 0; } - $partnership->statut = -1; - $partnership->firstname = GETPOST('firstname'); - $partnership->lastname = GETPOST('lastname'); - $partnership->address = GETPOST('address'); - $partnership->zip = GETPOST('zipcode'); - $partnership->town = GETPOST('town'); - $partnership->email = GETPOST('email'); - $partnership->country_id = GETPOST('country_id', 'int'); - $partnership->state_id = GETPOST('state_id', 'int'); + $events->statut = -1; + $events->firstname = GETPOST('firstname'); + $events->lastname = GETPOST('lastname'); + $events->address = GETPOST('address'); + $events->zip = GETPOST('zipcode'); + $events->town = GETPOST('town'); + $events->email = GETPOST('email'); + $events->country_id = GETPOST('country_id', 'int'); + $events->state_id = GETPOST('state_id', 'int'); //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); - $partnership->note_private = GETPOST('note_private'); + $event->note_private = GETPOST('note_private'); // Fill array 'array_options' with data from add form $extrafields->fetch_name_optionals_label($partnership->table_element); @@ -225,186 +246,23 @@ if (empty($reshook) && $action == 'add') { $error++; } - $result = $partnership->create($user); - if ($result > 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $object = $partnership; - - /* - $partnershipt = new PartnershipType($db); - $partnershipt->fetch($object->typeid); - - if ($object->email) { - $subject = ''; - $msg = ''; - - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->PARTNERSHIP_EMAIL_TEMPLATE_AUTOREGISTER; - - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - } - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $partnershipt->getMailOnValid()), $substitutionarray, $outputlangs); - - if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } - } - */ - - // Send email to the foundation to say a new member subscribed with autosubscribe form - if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && - !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) { - // Define link to login card - $appli = constant('DOL_APPLICATION_TITLE'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) { - if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { - $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core - } - } else { - $appli .= " ".DOL_VERSION; - } - } else { - $appli .= " ".DOL_VERSION; - } - - $to = $partnership->makeSubstitution(getDolGlobalString('MAIN_INFO_SOCIETE_MAIL')); - $from = getDolGlobalString('PARTNERSHIP_MAIL_FROM'); - $mailfile = new CMailFile( - '['.$appli.'] '.getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT', 'Partnership request'), - $to, - $from, - $partnership->makeSubstitution(getDolGlobalString('PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL')), - array(), - array(), - array(), - "", - "", - 0, - -1 - ); - - if (!$mailfile->sendfile()) { - dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); - } - } - - if (!empty($backtopage)) { - $urlback = $backtopage; - } elseif (!empty($conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION)) { - $urlback = $conf->global->PARTNERSHIP_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + if (!$error) { + $result = $event->create($user); + if ($result > 0) { + $db->commit(); + $urlback = DOL_URL_ROOT.'/public/partnership/new.php?action=confirm&id='.$event->id; + header('Location: '.$urlback); + exit; } else { - $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); + $db->rollback(); + $errmsg = $event->error; + $error++; } - - if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') { - if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') { - $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref); - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paybox') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref); - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'paypal') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref); - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'stripe') { - $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.$partnership->ref; - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$partnership->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } else { - dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment"); - exit; - } - } - - if (!empty($entity)) { - $urlback .= '&entity='.$entity; - } - dol_syslog("partnership ".$partnership->ref." was created, we redirect to ".$urlback); } else { $error++; - $errmsg .= join('
', $partnership->errors); + $errmsg .= join('
', $event->errors); } } - - if (!$error) { - $db->commit(); - - Header("Location: ".$urlback); - exit; - } else { - $db->rollback(); - } } // Action called after a submitted was send and member created successfully @@ -436,165 +294,492 @@ $formcompany = new FormCompany($db); $extrafields->fetch_name_optionals_label($partnership->table_element); // fetch optionals attributes and labels -llxHeaderVierge($langs->trans("NewPartnershipRequest")); +llxHeaderVierge($langs->trans("NewBookingRequest")); -print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center'); +print load_fiche_titre($langs->trans("NewBookingRequest"), '', '', 0, 0, 'center'); -print '
'; -print '
'; -print '
'; -if (!empty($conf->global->PARTNERSHIP_NEWFORM_TEXT)) { - print $langs->trans($conf->global->PARTNERSHIP_NEWFORM_TEXT)."
\n"; -} else { - print $langs->trans("NewPartnershipRequestDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n"; -} -print '
'; +// View -dol_htmloutput_errors($errmsg); +// Add new Events form +$contact = new Contact($db); -// Print form -print '
'."\n"; -print ''; -print ''; -print ''; - -print '
'; - -print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; -//print $langs->trans("FieldsWithIsForPublic",'**').'
'; - -print dol_get_fiche_head(''); - -print ''; - - -print ''."\n"; - -// Type -/* -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - $listoftype = $partnershipt->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; -} else { - $partnershipt->fetch($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE); - print ''; -} -*/ - -$partnershiptype = new PartnershipType($db); -$listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000); -$listofpartnership = array(); -foreach ($listofpartnershipobj as $partnershipobj) { - $listofpartnership[$partnershipobj->id] = $partnershipobj->label; -} - -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - print ''."\n"; -} else { - print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE]; - print ''; -} - -// Company -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// EMail -print ''."\n"; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print 'global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").''; -print dol_get_fiche_end(); + // Full day + print ''; } -print ''; + + print ''; + + $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep)); +if (GETPOST('datep', 'int', 1)) { + $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser'); +} + $datef = ($datef ? $datef : $object->datef); +if (GETPOST('datef', 'int', 1)) { + $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser'); +} +if (empty($datef) && !empty($datep)) { + if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) { + $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h'); + } +} + + // Date start + print ''; + + print ''; + + // Assigned to + print ''; + + // Done by +if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) { + print ''; +} + + // Location +if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { + print ''; +} + + // Status + print ''; + print ''; + +if (!empty($conf->categorie->enabled)) { + // Categories + print '"; +} + + print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $partnershipt->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('PartnershipType').' *'."\n"; - print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1); - print '
'.$langs->trans("Company").' *'; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print '
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").' *'; -//print img_picto('', 'email', 'class="pictofixedwidth"'); -print '
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6, 1); -print ' / '; -print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); -print '
'.$langs->trans('Country').''; -print img_picto('', 'country', 'class="pictofixedwidth"'); -$country_id = GETPOST('country_id', 'int'); -if (!$country_id && !empty($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->PARTNERSHIP_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); -} -if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; - } + $socpeopleassigned = GETPOST("socpeopleassigned", 'array'); +if (!empty($socpeopleassigned[0])) { + $result = $contact->fetch($socpeopleassigned[0]); + if ($result < 0) { + dol_print_error($db, $contact->error); } } -$country_code = getCountry($country_id, 2, $db, $langs); -print $form->select_country($country_id, 'country_id'); -print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } + + dol_set_focus("#label"); + +if (!empty($conf->use_javascript_ajax)) { + print "\n".''."\n"; +} + print ''; + print ''; + print ''; + print ''; + print ''; +if ($backtopage) { + print ''; +} +if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + print ''; +} + +if (GETPOST("actioncode", 'aZ09') == 'AC_RDV') { + print load_fiche_titre($langs->trans("AddActionRendezVous"), '', 'title_agenda'); +} else { + print load_fiche_titre($langs->trans("AddAnAction"), '', 'title_agenda'); +} + + print dol_get_fiche_head(); + + print ''; + + // Type of event +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + print ''; } -// Logo -//print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\n"; -print "
'.$langs->trans("Type").''; + $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? 'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT); + print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); + print $formactions->select_type_actions(GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1, 0, 1); // TODO Replace 0 with -2 in onlyautoornot print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Comments").'
\n"; + // Title + print '
'.$langs->trans("Date").''; -// Save -print '
'; -print ''; -if (!empty($backtopage)) { - print '     '; + // Recurring event + $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); +if ($userepeatevent) { + // Repeat + //print '
'; + print '        
'; + print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); + print ''; + $selectedrecurrulefreq = 'no'; + $selectedrecurrulebymonthday = ''; + $selectedrecurrulebyday = ''; + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { + $selectedrecurrulefreq = $reg[1]; + } + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { + $selectedrecurrulebymonthday = $reg[1]; + } + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { + $selectedrecurrulebyday = $reg[1]; + } + print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // If recurrulefreq is MONTHLY + print ''; + // If recurrulefreq is WEEKLY + print ''; + print ''; + print '
'; + //print '
'; + /* + print ''.$langs->trans("DateActionStart").''; + print ' - '; + print ''.$langs->trans("DateActionEnd").''; + */ + print ''; +if (GETPOST("afaire") == 1) { + print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo" +} else { + print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); +} + print '     -     '; +if (GETPOST("afaire") == 1) { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); +} else { + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); +} + print '
 
'.$langs->trans("ActionAffectedTo").''; + $listofuserid = array(); + $listofcontactid = array(); + $listofotherid = array(); + +if (empty($donotclearsession)) { + $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); + if ($assignedtouser) { + $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first + } + //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init + $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init + $_SESSION['assignedtouser'] = json_encode($listofuserid); +} else { + if (!empty($_SESSION['assignedtouser'])) { + $listofuserid = json_decode($_SESSION['assignedtouser'], true); + } + $firstelem = reset($listofuserid); + if (isset($listofuserid[$firstelem['id']])) { + $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing + } +} + print '
'; + print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); + print '
'; + print '
'.$langs->trans("ActionDoneBy").''; + print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOST("doneby", 'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); + print '
'.$langs->trans("Location").'
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; + $percent = $complete !=='' ? $complete : -1; +if (GETPOSTISSET('status')) { + $percent = GETPOST('status'); +} elseif (GETPOSTISSET('percentage')) { + $percent = GETPOST('percentage', 'int'); +} else { + if ($complete == '0' || GETPOST("afaire") == 1) { + $percent = '0'; + } elseif ($complete == 100 || GETPOST("afaire") == 2) { + $percent = 100; + } +} + $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); + print '
'.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); + print "
'; -print "
\n"; -print "
"; -print '
'; + print '


'; + + + print ''; + +if (!empty($conf->societe->enabled)) { + // Related company + print ''; + + // Related contact + print ''; +} + + // Project +if (!empty($conf->project->enabled)) { + $langs->load("projects"); + + $projectid = GETPOST('projectid', 'int'); + + print ''; + + print ''; +} + + // Object linked +if (!empty($origin) && !empty($originid)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + $hasPermissionOnLinkedObject = 0; + if ($user->hasRight($origin, 'read')) { + $hasPermissionOnLinkedObject = 1; + } + //var_dump('origin='.$origin.' originid='.$originid.' hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject); + + if (! in_array($origin, array('societe', 'project', 'task', 'user'))) { + // We do not use link for object that already contains a hard coded field to make links with agenda events + print ''; + print ''; + } +} + + $reg = array(); +if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) { + $object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]); +} + + // Priority +if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) { + print ''; +} + + // Description + print ''; + + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; +if (empty($reshook)) { + print $object->showOptionals($extrafields, 'create', $parameters); +} + + print '
'.$langs->trans("ActionOnCompany").''; + if (GETPOST('socid', 'int') > 0) { + $societe = new Societe($db); + $societe->fetch(GETPOST('socid', 'int')); + print $societe->getNomUrl(1); + print ''; + } else { + $events = array(); + $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 + if (!empty($user->socid)) { + print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300'); + } else { + print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300'); + } + } + print '
'.$langs->trans("ActionOnContact").''; + $preselectedids = GETPOST('socpeopleassigned', 'array'); + if (GETPOST('contactid', 'int')) { + $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); + } + if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int'); + print img_picto('', 'contact', 'class="paddingrightonly"'); + print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print '
'.$langs->trans("Project").''; + print img_picto('', 'project', 'class="pictofixedwidth"'); + print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + + print ' '; + print ''; + $urloption = '?action=create&donotclearsession=1'; + $url = dol_buildpath('comm/action/card.php', 2).$urloption; + + // update task list + print "\n".''."\n"; + + print '
'.$langs->trans("Task").''; + print img_picto('', 'projecttask', 'class="paddingrightonly"'); + $projectsListId = false; + if (!empty($projectid)) { + $projectsListId = $projectid; + } + + $tid = GETPOSTISSET("projecttaskid") ? GETPOST("projecttaskid", 'int') : (GETPOSTISSET("taskid") ? GETPOST("taskid", 'int') : ''); + + $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500', $projectsListId); + print '
'.$langs->trans("LinkedObject").''; + if ($hasPermissionOnLinkedObject) { + print dolGetElementUrl($originid, $origin, 1); + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + } + print '
'.$langs->trans("Priority").''; + print ''; + print '
'.$langs->trans("Description").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%'); + $doleditor->Create(); + print '
'; + + +if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) { + //checkbox create reminder + print '
'; + print '
'; + print '

'; + + print ''; + + print "\n".''."\n"; +} + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("Add"); + + print ""; llxFooterVierge();