/** * Delete contact * * @param int $id Contact ID * @return array * * @url DELETE contact/{id} */ function delete($id) { if (!DolibarrApiAccess::$user->rights->contact->supprimer) { throw new RestException(401); } $result = $this->contact->fetch($id); if (!$result) { throw new RestException(404, 'Contact not found'); } if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } return $this->contact->delete($id); }
/** * Get object * * @param int $id Object id * @return object Object loaded */ function getObject($id) { $ret = $this->getInstanceDao(); if (is_object($this->object) && method_exists($this->object, 'fetch')) { if (!empty($id)) { $this->object->fetch($id); } } else { $object = new Contact($this->db); if (!empty($id)) { $object->fetch($id); } $this->object = $object; } }
public function json() { // find out who is light and who is heavy // (light => less than 0.66 * (80th percentile)) $nass = array(); foreach ($this->r as $cid => $x) { $nass[] = count($x); } sort($nass); $heavy_boundary = 0; if (count($nass)) { $heavy_boundary = 0.66 * $nass[(int) (0.8 * count($nass))]; } $contacts = pcMembers(); $need_contacts = []; foreach ($this->r as $cid => $x) { if (!isset($contacts[$cid]) && ctype_digit($cid)) { $need_contacts[] = $cid; } } if (count($need_contacts)) { $result = Dbl::q("select firstName, lastName, affiliation, email, contactId, roles, contactTags, disabled from ContactInfo where contactId ?a", $need_contacts); while ($result && ($row = Contact::fetch($result))) { $contacts[$row->contactId] = $row; } } $users = array(); $tags = $this->contact->can_view_reviewer_tags(); foreach ($this->r as $cid => $x) { if ($cid != "conflicts") { $users[$cid] = $u = (object) array(); $p = get($contacts, $cid); if ($p) { $u->name = Text::name_text($p); } if (count($x) < $heavy_boundary) { $u->light = true; } if ($p && $tags && ($t = $p->viewable_color_classes($this->contact))) { $u->color_classes = $t; } } } return (object) array("reviews" => $this->r, "deadlines" => $this->dl, "users" => $users); }
private static function modify_password_mail($where, $dopassword, $sendtype, $ids) { $j = (object) array("ok" => true); $result = Dbl::qe("select * from ContactInfo where {$where} and contactId ?a", $ids); while ($result && ($Acct = Contact::fetch($result))) { if ($dopassword) { $Acct->change_password(null, null, Contact::CHANGE_PASSWORD_NO_CDB); } if ($sendtype && !$Acct->disabled) { $Acct->sendAccountInfo($sendtype, false); } else { if ($sendtype) { $j->warnings[] = "Not sending mail to disabled account " . htmlspecialchars($Acct->email) . "."; } } } return $j; }
/** * Show event of a particular day * * @param DoliDB $db Database handler * @param int $day Day * @param int $month Month * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day * @param array $eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. * @return void */ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60) { global $user, $conf, $langs; global $action, $filter, $filtert, $status, $actioncode; // Filters used into search form global $theme_datacolor; global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused; print "\n" . '<div id="dayevent_' . sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day) . '" class="dayevent">'; // Line with title of day $curtime = dol_mktime(0, 0, 0, $month, $day, $year); print '<table class="nobordernopadding" width="100%">' . "\n"; print '<tr><td align="left" class="nowrap">'; print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?'; print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year; print $newparam; print '">'; if ($showinfo) { print dol_print_date($curtime, 'daytextshort'); } else { print dol_print_date($curtime, '%d'); } print '</a>'; print '</td><td align="right" class="nowrap">'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { $newparam .= '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year; //$param='month='.$monthshown.'&year='.$year; $hourminsec = '100000'; print '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&datep=' . sprintf("%04d%02d%02d", $year, $month, $day) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '">'; print img_picto($langs->trans("NewAction"), 'edit_add.png'); print '</a>'; } print '</td></tr>' . "\n"; // Line with td contains all div of each events print '<tr height="' . $minheight . '"><td valign="top" colspan="2" class="sortable" style="padding-bottom: 2px;">'; print '<div style="width: 100%; position: relative;">'; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); $i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day); $nextindextouse = count($colorindexused); // At first run this is 0, so fist user has 0, next 1, ... //print $nextindextouse; foreach ($eventarray as $daykey => $notused) { $annee = date('Y', $daykey); $mois = date('m', $daykey); $jour = date('d', $daykey); if ($day == $jour && $month == $mois && $year == $annee) { foreach ($eventarray[$daykey] as $index => $event) { if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) { $keysofuserassigned = array_keys($event->userassigned); $ponct = $event->date_start_in_calendar == $event->date_end_in_calendar; // Define $color (Hex string like '0088FF') and $cssclass of event $color = -1; $colorindex = -1; if (in_array($user->id, $keysofuserassigned)) { $nummytasks++; $cssclass = 'family_mytasks'; if (empty($cacheusers[$event->userownerid])) { $newuser = new User($db); $newuser->fetch($event->userownerid); $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) if (!empty($cacheusers[$event->userownerid]->color)) { $color = $cacheusers[$event->userownerid]->color; } } else { if ($event->type_code == 'ICALEVENT') { $numical++; if (!empty($event->icalname)) { if (!isset($numicals[dol_string_nospecial($event->icalname)])) { $numicals[dol_string_nospecial($event->icalname)] = 0; } $numicals[dol_string_nospecial($event->icalname)]++; } $color = $event->icalcolor; $cssclass = !empty($event->icalname) ? 'family_ext' . md5($event->icalname) : 'family_other'; } else { if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unmovable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; $cssclass = 'family_other'; if (empty($cacheusers[$event->userownerid])) { $newuser = new User($db); $newuser->fetch($event->userownerid); $cacheusers[$event->userownerid] = $newuser; } //var_dump($cacheusers[$event->userownerid]->color); // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) if (!empty($cacheusers[$event->userownerid]->color)) { $color = $cacheusers[$event->userownerid]->color; } } } } if ($color == -1) { // Define color index if not yet defined $idusertouse = $event->userownerid ? $event->userownerid : 0; if (isset($colorindexused[$idusertouse])) { $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user } else { $colorindex = $nextindextouse; $colorindexused[$idusertouse] = $colorindex; if (!empty($theme_datacolor[$nextindextouse + 1])) { $nextindextouse++; } // Prepare to use next color } //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>'; // Define color $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } $cssclass = $cssclass . ' ' . $cssclass . '_day_' . $ymd; // Defined style to disable drag and drop feature if ($event->type_code == 'AC_OTH_AUTO') { $cssclass .= " unmovable"; } else { if ($event->type_code == 'ICALEVENT') { $cssclass .= " unmovable"; } else { if ($event->date_end_in_calendar && date('Ymd', $event->date_start_in_calendar) != date('Ymd', $event->date_end_in_calendar)) { $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { $cssclass .= " unmovable"; } } else { $cssclass .= " movable"; } } } $h = ''; $nowrapontd = 1; if ($action == 'show_day') { $h = 'height: 100%; '; $nowrapontd = 0; } if ($action == 'show_week') { $h = 'height: 100%; '; $nowrapontd = 0; } // Show rect of event print "\n"; print '<!-- start event ' . $i . ' --><div id="event_' . $ymd . '_' . $i . '" class="event ' . $cssclass . '"'; //print ' style="height: 100px;'; //print ' position: absolute; top: 40px; width: 50%;'; //print '"'; print '>'; print '<ul class="cal_event" style="' . $h . '">'; // always 1 li per ul, 1 ul per event print '<li class="cal_event" style="' . $h . '">'; print '<table class="cal_event' . (empty($event->transparency) ? '' : ' cal_event_busy') . '" style="' . $h; print 'background: #' . $color . '; background: -webkit-gradient(linear, left top, left bottom, from(#' . $color . '), to(#' . dol_color_minus($color, 1) . '));'; //if (! empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));'; //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;'; print ' -moz-border-radius:4px;" width="100%"><tr>'; print '<td class="' . ($nowrapontd ? 'nowrap ' : '') . 'cal_event' . ($event->type_code == 'BIRTHDAY' ? ' cal_event_birthday' : '') . '">'; if ($event->type_code == 'BIRTHDAY') { print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); } if ($event->type_code != 'BIRTHDAY') { // Picto if (empty($event->fulldayevent)) { //print $event->getNomUrl(2).' '; } // Date if (empty($event->fulldayevent)) { //print '<strong>'; $daterange = ''; // Show hours (start ... end) $tmpyearstart = date('Y', $event->date_start_in_calendar); $tmpmonthstart = date('m', $event->date_start_in_calendar); $tmpdaystart = date('d', $event->date_start_in_calendar); $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { $daterange .= '-'; } //else //print '...'; } } if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { $daterange .= '...'; } } // Hour end if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); } // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user } //print $daterange; if ($event->type_code != 'ICALEVENT') { $savlabel = $event->libelle; $event->libelle = $daterange; print $event->getNomUrl(0); $event->libelle = $savlabel; } else { print $daterange; } //print '</strong> '; print "<br>\n"; } else { if ($showinfo) { print $langs->trans("EventOnFullDay") . "<br>\n"; } } // Show title if ($event->type_code == 'ICALEVENT') { print dol_trunc($event->libelle, $maxnbofchar); } else { print $event->getNomUrl(0, $maxnbofchar, 'cal_event'); } if ($event->type_code == 'ICALEVENT') { print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')'; } // If action related to company / contact $linerelatedto = ''; $length = 16; if (!empty($event->societe->id) && !empty($event->contact->id)) { $length = round($length / 2); } if (!empty($event->societe->id) && $event->societe->id > 0) { if (!isset($cachethirdparties[$event->societe->id]) || !is_object($cachethirdparties[$event->societe->id])) { $thirdparty = new Societe($db); $thirdparty->fetch($event->societe->id); $cachethirdparties[$event->societe->id] = $thirdparty; } else { $thirdparty = $cachethirdparties[$event->societe->id]; } if (!empty($thirdparty->id)) { $linerelatedto .= $thirdparty->getNomUrl(1, '', $length); } } if (!empty($event->contact->id) && $event->contact->id > 0) { if (!is_object($cachecontacts[$event->contact->id])) { $contact = new Contact($db); $contact->fetch($event->contact->id); $cachecontacts[$event->contact->id] = $contact; } else { $contact = $cachecontacts[$event->contact->id]; } if ($linerelatedto) { $linerelatedto .= ' / '; } if (!empty($contact->id)) { $linerelatedto .= $contact->getNomUrl(1, '', $length); } } if ($linerelatedto) { print '<br>' . $linerelatedto; } } // Show location if ($showinfo) { if ($event->location) { print '<br>'; print $langs->trans("Location") . ': ' . $event->location; } } print '</td>'; // Status - Percent print '<td align="right" class="nowrap cal_event_right">'; if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { print $event->getLibStatut(3, 1); } else { print ' '; } print '</td></tr></table>'; print '</li>'; print '</ul>'; print '</div><!-- end event ' . $i . ' -->' . "\n"; $i++; } else { print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?action=' . $action . '&maxprint=0&month=' . $monthshown . '&year=' . $year; print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : ''); print $filtert ? '&filtert=' . $filtert : ''; print $actioncode != '' ? '&actioncode=' . $actioncode : ''; print '">' . img_picto("all", "1downarrow_selected.png") . ' ...'; print ' +' . (count($eventarray[$daykey]) - $maxprint); print '</a>'; break; //$ok=false; // To avoid to show twice the link } } break; } } if (!$i) { print ' '; } if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>'; //print ' +'.(count($eventarray[$daykey])-$maxprint); print '<script type="text/javascript">' . "\n"; print 'jQuery(document).ready(function () {' . "\n"; print 'jQuery("#more_' . $ymd . '").click(function() { reinit_day_' . $ymd . '(); });' . "\n"; print 'function reinit_day_' . $ymd . '() {' . "\n"; print 'var nb=0;' . "\n"; // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached print 'jQuery(".family_mytasks_day_' . $ymd . '").toggle();'; print '}' . "\n"; print '});' . "\n"; print '</script>' . "\n"; } print '</div>'; print '</td></tr>'; print '</table></div>' . "\n"; }
function requestReview($email) { global $Conf, $Me, $Error, $prow; $Them = Contact::create(array("name" => @$_REQUEST["name"], "email" => $email)); if (!$Them) { if (trim($email) === "" || !validate_email($email)) { Conf::msg_error("“" . htmlspecialchars(trim($email)) . "” is not a valid email address."); $Error["email"] = true; } else { Conf::msg_error("Error while finding account for “" . htmlspecialchars(trim($email)) . ".”"); } return false; } $reason = trim(defval($_REQUEST, "reason", "")); $round = $Conf->current_round(); if (isset($_REQUEST["round"]) && $_REQUEST["round"] != "" && ($rname = $Conf->sanitize_round_name($_REQUEST["round"])) !== false) { $round = $Conf->round_number($rname, false); } // look up the requester $Requester = $Me; if ($Conf->setting("extrev_chairreq")) { $result = Dbl::qe("select firstName, lastName, u.email, u.contactId from ReviewRequest rr join ContactInfo u on (u.contactId=rr.requestedBy) where paperId={$prow->paperId} and rr.email=?", $Them->email); if ($result && ($recorded_requester = Contact::fetch($result))) { $Requester = $recorded_requester; } } Dbl::qe_raw("lock tables PaperReview write, PaperReviewRefused write, ReviewRequest write, ContactInfo read, PaperConflict read, ActionLog write"); // NB caller unlocks tables on error // check for outstanding review request if (!($result = requestReviewChecks(Text::user_html($Them), $Them->contactId))) { return $result; } // at this point, we think we've succeeded. // store the review request $Me->assign_review($prow->paperId, $Them->contactId, REVIEW_EXTERNAL, ["mark_notify" => true, "requester_contact" => $Requester, "requested_email" => $Them->email, "round_number" => $round]); Dbl::qx_raw("unlock tables"); // send confirmation email HotCRPMailer::send_to($Them, "@requestreview", $prow, array("requester_contact" => $Requester, "other_contact" => $Requester, "reason" => $reason)); $Conf->confirmMsg("Created a request to review paper #{$prow->paperId}."); return true; }
/** * Function to build a document on disk using the generic odt module. * * @param Commande $object Object source to build document * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs, $srctemplatepath) { global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); return -1; } if (!is_object($outputlangs)) { $outputlangs = $langs; } $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("projects"); if ($conf->projet->dir_output) { // If $object is id instead of object if (!is_object($object)) { $id = $object; $object = new Task($this->db); $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } } $project = new Project($this->db); $project->fetch($object->fk_project); $dir = $conf->projet->dir_output . "/" . $project->ref . "/"; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".odt"; if (!file_exists($dir)) { print '$dir' . $dir; if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); $newfiletmp = preg_replace('/\\.(ods|odt)/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; $file = $dir . '/' . $newfiletmp . '.odt'; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; //print "conf->societe->dir_temp=".$conf->societe->dir_temp; dol_mkdir($conf->projet->dir_temp); $socobject = $object->thirdparty; // Make substitution $substitutionarray = array('__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email); complete_substitutions_array($substitutionarray, $langs, $object); // Open and load template require_once ODTPHP_PATH . 'odf.php'; try { $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->projet->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}')); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } // After construction $odfHandler->contentXml contains content and // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN lines --]*[!-- END lines --] //print html_entity_decode($odfHandler->__toString()); //print exit; // Make substitutions into odt of user info $array_user = $this->get_substitutionarray_user($user, $outputlangs); $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); $array_objet = $this->get_substitutionarray_object($project, $outputlangs); $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } } else { $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { } } // Replace tags of lines for tasks try { // Security check $socid = 0; if (!empty($project->fk_soc)) { $socid = $project->fk_soc; } $tmparray = $this->get_substitutionarray_tasks($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); foreach ($tmparray as $key => $val) { try { $odfHandler->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } // Replace tags of lines for contacts task $sourcearray = array('internal', 'external'); $contact_arrray = array(); foreach ($sourcearray as $source) { $contact_temp = $object->liste_contact(-1, $source); if (is_array($contact_temp) && count($contact_temp) > 0) { $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if (is_array($contact_arrray) && count($contact_arrray) > 0) { $listlinestaskres = $odfHandler->setSegment('tasksressources'); foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); $contact['socname'] = $mysoc->name; } elseif ($contact['source'] == 'external') { $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); $soc = new Societe($this->db); $soc->fetch($contact['socid']); $contact['socname'] = $soc->name; } $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlinestaskres->merge(); } $odfHandler->mergeSegment($listlinestaskres); } //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; $sql .= ", u.name, u.firstname"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task_time as t"; $sql .= " , " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE t.fk_task =" . $object->id; $sql .= " AND t.fk_user = u.rowid"; $sql .= " ORDER BY t.task_date DESC"; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $tasks = array(); $listlinestasktime = $odfHandler->setSegment('taskstimes'); while ($i < $num) { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { $row['fullcivname'] = ''; } $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlinestasktime->merge(); $i++; } $this->db->free($resql); $odfHandler->mergeSegment($listlinestasktime); } // Replace tags of project files $listtasksfiles = $odfHandler->setSegment('tasksfiles'); $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($project->ref) . '/' . dol_sanitizeFileName($object->ref); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); foreach ($tmparray as $key => $val) { try { $listtasksfiles->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listtasksfiles->merge(); } //$listlines->merge(); $odfHandler->mergeSegment($listtasksfiles); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of project files try { $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts $sourcearray = array('internal', 'external'); $contact_arrray = array(); foreach ($sourcearray as $source) { $contact_temp = $project->liste_contact(-1, $source); if (is_array($contact_temp) && count($contact_temp) > 0) { $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if (is_array($contact_arrray) && count($contact_arrray) > 0) { try { $listlines = $odfHandler->setSegment('projectcontacts'); foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); $contact['socname'] = $mysoc->name; } elseif ($contact['source'] == 'external') { $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); $soc = new Societe($this->db); $soc->fetch($contact['socid']); $contact['socname'] = $soc->name; } $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } } // Call the beforeODTSave hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } } else { try { $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } } $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } $odfHandler = null; // Destroy object return 1; // Success } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } return -1; }
static function getHeadForObject($tab_object, $fk_object) { global $db, $conf, $langs, $user; $head = array(); if (empty($tab_object)) { return $head; } if ($tab_object === 'product') { dol_include_once('/product/class/product.class.php'); dol_include_once('/core/lib/product.lib.php'); $object = new Product($db); $object->fetch($fk_object); $head = product_prepare_head($object); } else { if ($tab_object === 'thirdparty') { dol_include_once('/societe/class/societe.class.php'); dol_include_once('/core/lib/company.lib.php'); $object = new Societe($db); $object->fetch($fk_object); $head = societe_prepare_head($object); } else { if ($tab_object === 'contact') { dol_include_once('/contact/class/contact.class.php'); dol_include_once('/core/lib/contact.lib.php'); $object = new Contact($db); $object->fetch($fk_object); $head = contact_prepare_head($object); } else { if ($tab_object === 'user') { dol_include_once('/user/class/user.class.php'); dol_include_once('/core/lib/usergroups.lib.php'); $object = new User($db); $object->fetch($fk_object); $head = user_prepare_head($object); } else { if ($tab_object === 'group') { dol_include_once('/user/class/usergroup.class.php'); dol_include_once('/lib/usergroups.lib.php'); $object = new UserGroup($db); $object->fetch($fk_object); $head = group_prepare_head($object); } else { if ($tab_object === 'project') { dol_include_once('/projet/class/project.class.php'); dol_include_once('/core/lib/project.lib.php'); $object = new Project($db); $object->fetch($fk_object); $head = project_prepare_head($object); } } } } } } return $head; }
$formmail->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; $formmail->substit['__PROJECT_REF__'] = is_object($object->projet) ? $object->projet->ref : ''; $formmail->substit['__PROJECT_NAME__'] = is_object($object->projet) ? $object->projet->title : ''; $formmail->substit['__PERSONALIZED__'] = ''; $formmail->substit['__CONTACTCIVNAME__'] = ''; // Find the good contact adress $custcontact = ''; $contactarr = array(); $contactarr = $object->liste_contact(-1, 'external'); if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { if ($contact['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { // TODO Use code and not label require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $contactstatic = new Contact($db); $contactstatic->fetch($contact['id']); $custcontact = $contactstatic->getFullName($langs, 1); } } if (!empty($custcontact)) { $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; } } // Tableau des parametres complementaires du post $formmail->param['action'] = $action; $formmail->param['models'] = $modelmail; $formmail->param['models_id'] = GETPOST('modelmailselected', 'int'); $formmail->param['facid'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; // Init list of files if (GETPOST("mode") == 'init') {
require_once DOL_DOCUMENT_ROOT . "/contact/class/contact.class.php"; require_once DOL_DOCUMENT_ROOT . "/core/lib/contact.lib.php"; $langs->load("companies"); // Security check $contactid = isset($_GET["id"]) ? $_GET["id"] : ''; if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); /* * View */ llxHeader('', $langs->trans("ContactsAddresses"), 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); $form = new Form($db); $contact = new Contact($db); $contact->fetch($_GET["id"], $user); $head = contact_prepare_head($contact); dol_fiche_head($head, 'exportimport', $langs->trans("ContactsAddresses"), 0, 'contact'); /* * Fiche en mode visu */ print '<table class="border" width="100%">'; // Ref print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="3">'; print $form->showrefnav($contact, 'id'); print '</td></tr>'; // Name print '<tr><td width="20%">' . $langs->trans("Lastname") . ' / ' . $langs->trans("Label") . '</td><td>' . $contact->name . '</td>'; print '<td width="20%">' . $langs->trans("Firstname") . '</td><td width="25%">' . $contact->firstname . '</td></tr>'; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
// fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('contact'); $search_array_options = $extrafields->getOptionalsFromPost($extralabels, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array('p.lastname' => 'Lastname', 'p.firstname' => 'Firstname', 'p.email' => 'EMail', 's.nom' => "ThirdParty"); // Definition of fields for list $arrayfields = array('p.lastname' => array('label' => $langs->trans("Lastname"), 'checked' => 1), 'p.firstname' => array('label' => $langs->trans("Firsname"), 'checked' => 1), 'p.poste' => array('label' => $langs->trans("Post"), 'checked' => 1), 'p.town' => array('label' => $langs->trans("Town"), 'checked' => 0), 'p.zip' => array('label' => $langs->trans("Zip"), 'checked' => 0), 'p.phone' => array('label' => $langs->trans("PhonePro"), 'checked' => 1), 'p.phone_perso' => array('label' => $langs->trans("PhonePerso"), 'checked' => 0), 'p.phone_mobile' => array('label' => $langs->trans("PhoneMobile"), 'checked' => 1), 'p.fax' => array('label' => $langs->trans("Fax"), 'checked' => 1), 'p.email' => array('label' => $langs->trans("Email"), 'checked' => 1), 'p.skype' => array('label' => $langs->trans("Skype"), 'checked' => 1, 'enabled' => !empty($conf->skype->enabled)), 'p.thirdparty' => array('label' => $langs->trans("ThirdParty"), 'checked' => 1, 'enabled' => empty($conf->global->SOCIETE_DISABLE_CONTACTS)), 'p.priv' => array('label' => $langs->trans("ContactVisibility"), 'checked' => 1, 'position' => 200), 'p.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500), 'p.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500), 'p.statut' => array('label' => $langs->trans("Status"), 'checked' => 1, 'position' => 1000)); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { foreach ($extrafields->attribute_label as $key => $val) { $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]); } } $object = new Contact($db); if (($id > 0 || !empty($ref)) && $action != 'add') { $result = $object->fetch($id, $ref); if ($result < 0) { dol_print_error($db); } } /* * Actions */ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; if (empty($reshook)) {
function show_pset_table($pset) { global $Conf, $Me, $Now, $Profile, $LastPsetFix; echo '<div id="', $pset->urlkey, '">'; echo "<h3>", htmlspecialchars($pset->title), "</h3>"; if ($Me->privChair) { show_pset_actions($pset); } if ($pset->disabled) { echo "</div>\n"; return; } $t0 = $Profile ? microtime(true) : 0; // load students if ($Conf->opt("restrictRepoView")) { $view = "l2.link repoviewable"; $viewjoin = "left join ContactLink l2 on (l2.cid=c.contactId and l2.type=" . LINK_REPOVIEW . " and l2.link=l.link)\n"; } else { $view = "4 repoviewable"; $viewjoin = ""; } $result = Dbl::qe("select c.contactId, c.firstName, c.lastName, c.email,\n\tc.huid, c.github_username, c.seascode_username, c.anon_username, c.extension, c.disabled, c.dropped, c.roles, c.contactTags,\n\tgroup_concat(pl.link) pcid, group_concat(rpl.link) rpcid,\n\tr.repoid, r.cacheid, r.heads, r.url, r.open, r.working, r.lastpset, r.snapcheckat, {$view},\n\trg.gradehash, rg.gradercid, rg.placeholder, rg.placeholder_at\n\tfrom ContactInfo c\n\tleft join ContactLink l on (l.cid=c.contactId and l.type=" . LINK_REPO . " and l.pset={$pset->id})\n\t{$viewjoin}\n\tleft join Repository r on (r.repoid=l.link)\n\tleft join ContactLink pl on (pl.cid=c.contactId and pl.type=" . LINK_PARTNER . " and pl.pset={$pset->id})\n\tleft join ContactLink rpl on (rpl.cid=c.contactId and rpl.type=" . LINK_BACKPARTNER . " and rpl.pset={$pset->id})\n\tleft join RepositoryGrade rg on (rg.repoid=r.repoid and rg.pset={$pset->id})\n\twhere (c.roles&" . Contact::ROLE_PCLIKE . ")=0\n\tand (rg.repoid is not null or not c.dropped)\n\tgroup by c.contactId, r.repoid"); $t1 = $Profile ? microtime(true) : 0; $anonymous = $pset->anonymous; if (req("anonymous") !== null && $Me->privChair) { $anonymous = !!req("anonymous"); } $students = array(); while ($result && ($s = Contact::fetch($result))) { $s->set_anonymous($anonymous); Contact::set_sorter($s, req("sort")); $students[$s->contactId] = $s; // maybe lastpset links are out of order if ($s->lastpset < $pset) { $LastPsetFix = true; } } uasort($students, "Contact::compare"); $checkbox = $Me->privChair || !$pset->gitless && $pset->runners; $rows = array(); $max_ncol = 0; $incomplete = array(); $pcmembers = pcMembers(); $jx = []; foreach ($students as $s) { if (!$s->visited) { $row = (object) ["student" => $s, "text" => "", "ptext" => []]; $j = render_pset_row($pset, $students, $s, $row, $pcmembers, $anonymous); if ($s->pcid) { foreach (array_unique(explode(",", $s->pcid)) as $pcid) { if (isset($students[$pcid])) { $jj = render_pset_row($pset, $students, $students[$pcid], $row, $pcmembers, $anonymous); $j["partners"][] = $jj; } } } if ($row->sortprefix) { $j["boring"] = true; } $jx[$row->sortprefix . $s->sorter] = $j; $max_ncol = max($max_ncol, $row->ncol); if ($s->incomplete) { $u = $Me->user_linkpart($s); $incomplete[] = '<a href="' . hoturl("pset", array("pset" => $pset->urlkey, "u" => $u, "sort" => req("sort"))) . '">' . htmlspecialchars($u) . '</a>'; } } } if (count($incomplete)) { echo '<div id="incomplete_pset', $pset->id, '" style="display:none" class="merror">', '<strong>', htmlspecialchars($pset->title), '</strong>: ', 'Your grading is incomplete. Missing grades: ', join(", ", $incomplete), '</div>', '<script>jQuery("#incomplete_pset', $pset->id, '").remove().show().appendTo("#incomplete_notices")</script>'; } if ($checkbox) { echo Ht::form_div(hoturl_post("index", array("pset" => $pset->urlkey, "save" => 1))); } $sort_key = $anonymous ? "anon_username" : "username"; usort($jx, function ($a, $b) use($sort_key) { if (get($a, "boring") != get($b, "boring")) { return get($a, "boring") ? 1 : -1; } return strcmp($a[$sort_key], $b[$sort_key]); }); echo '<table class="s61', $anonymous ? " s61anonymous" : "", '" id="pa-pset' . $pset->id . '"></table>'; $jd = ["checkbox" => $checkbox, "anonymous" => $anonymous, "grade_keys" => array_keys($pset->grades), "gitless" => $pset->gitless, "gitless_grades" => $pset->gitless_grades, "urlpattern" => hoturl("pset", ["pset" => $pset->urlkey, "u" => "@", "sort" => req("sort")])]; $i = $nintotal = $last_in_total = 0; foreach ($pset->grades as $ge) { if (!$ge->no_total) { ++$nintotal; $last_in_total = $ge->name; } ++$i; } if ($nintotal > 1) { $jd["need_total"] = true; } else { if ($nintotal == 1) { $jd["total_key"] = $last_in_total; } } echo Ht::unstash(), '<script>pa_render_pset_table(', $pset->id, ',', json_encode($jd), ',', json_encode(array_values($jx)), ')</script>'; if ($Me->privChair && !$pset->gitless_grades) { echo "<div class='g'></div>"; $sel = array("none" => "N/A"); foreach (pcMembers() as $pcm) { $sel[$pcm->email] = Text::name_html($pcm); } $sel["__random__"] = "Random"; echo '<span class="nb" style="padding-right:2em">', Ht::select("grader", $sel, "none"), Ht::submit("setgrader", "Set grader"), '</span>'; } if (!$pset->gitless) { $sel = array(); foreach ($pset->runners as $r) { if ($Me->can_run($pset, $r)) { $sel[$r->name] = htmlspecialchars($r->title); } } if (count($sel)) { echo '<span class="nb" style="padding-right:2em">', Ht::select("runner", $sel), Ht::submit("runmany", "Run all"), '</span>'; } } if ($checkbox) { echo "</div></form>\n"; } if ($Profile) { $t2 = microtime(true); echo sprintf("<div>Δt %.06f DB, %.06f total</div>", $t1 - $t0, $t2 - $t0); } echo "</div>\n"; }
} */ $sql = "SELECT rowid"; $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $ldap = new Ldap(); $ldap->connect_bind(); while ($i < $num) { $ldap->error = ""; $obj = $db->fetch_object($resql); $contact = new Contact($db); $contact->id = $obj->rowid; $contact->fetch($contact->id); print $langs->trans("UpdateContact") . " rowid=" . $contact->id . " " . $contact->getFullName($langs); $oldobject = $contact; $oldinfo = $oldobject->_load_ldap_info(); $olddn = $oldobject->_load_ldap_dn($oldinfo); $info = $contact->_load_ldap_info(); $dn = $contact->_load_ldap_dn($info); $result = $ldap->add($dn, $info, $user); // Wil fail if already exists $result = $ldap->update($dn, $info, $user, $olddn); if ($result > 0) { print " - " . $langs->trans("OK"); } else { $error++; print " - " . $langs->trans("KO") . ' - ' . $ldap->error; }
function user_prev_next($user, $pset) { global $Conf; $result = $Conf->qe("select c.contactId, c.firstName, c.lastName, c.email,\n\tc.huid, c.anon_username, c.github_username, c.seascode_username, c.extension, group_concat(pl.link) pcid\n\tfrom ContactInfo c\n\tleft join ContactLink pl on (pl.cid=c.contactId and pl.type=" . LINK_PARTNER . " and pl.pset={$pset->id})\n\twhere (c.roles&" . Contact::ROLE_PCLIKE . ")=0 and not c.dropped\n\tgroup by c.contactId"); $sort = req("sort"); $students = array(); while ($result && ($s = Contact::fetch($result))) { $s->set_anonymous($user->is_anonymous); Contact::set_sorter($s, $sort); $students[$s->contactId] = $s; } uasort($students, "Contact::compare"); $links = array(null, null); $pos = 0; $uid = is_object($user) ? $user->contactId : $user; // mark user's partners as visited if (($s = get($students, $uid)) && $s->pcid) { foreach (explode(",", $s->pcid) as $pcid) { if ($ss = get($students, $pcid)) { $ss->visited = true; } } } foreach ($students as $s) { if ($s->contactId == $uid) { $pos = 1; } else { if (!get($s, "visited")) { $links[$pos] = $s; if ($pos) { break; } $s->visited = true; if ($s->pcid) { foreach (explode(",", $s->pcid) as $pcid) { if ($ss = get($students, $pcid)) { $ss->visited = true; } } } } } } if ($pos == 0) { $links[0] = null; } return $links; }
print '</td></tr>'; // Company / Contact if (! empty($conf->societe->enabled)) { print '<tr><td width="25%">'.$langs->trans("LinkToCompanyContact").'</td>'; print '<td>'; if ($object->societe_id > 0) { $societe = new Societe($db); $societe->fetch($object->societe_id); print $societe->getNomUrl(1,''); if ($object->contact_id) { $contact = new Contact($db); $contact->fetch($object->contact_id); print ' / <a href="'.DOL_URL_ROOT.'/contact/card.php?id='.$object->contact_id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).'</a>'; } } else { print $langs->trans("ThisUserIsNot"); } print ' ('.$langs->trans("UseTypeFieldToChange").')'; print '</td>'; print "</tr>\n"; } // Module Adherent if (! empty($conf->adherent->enabled)) {
* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * \file htdocs/contact/vcard.php * \ingroup societe * \brief Onglet vcard d'un contact */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/vcard.class.php'; $id = GETPOST('id', 'int'); // Security check $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $contact = new Contact($db); $result = $contact->fetch($id); $physicalperson = 1; $company = new Societe($db); if ($contact->socid) { $result = $company->fetch($contact->socid); //print "ee"; } // We create VCard $v = new vCard(); $v->setProdId('Dolibarr ' . DOL_VERSION); $v->setUid('DOLIBARR-CONTACTID-' . $contact->id); $v->setName($contact->lastname, $contact->firstname, "", "", ""); $v->setFormattedName($contact->getFullName($langs)); // By default, all informations are for work (except phone_perso and phone_mobile) $v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); $v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE");
function pcMembers() { global $Conf, $Opt, $PcMembersCache; if (!@$PcMembersCache || $Conf->setting("pc") <= 0 || $PcMembersCache[0] < $Conf->setting("pc") || $PcMembersCache[1] != @$Opt["sortByLastName"]) { $pc = array(); $result = Dbl::q("select firstName, lastName, affiliation, email, contactId, roles, contactTags, disabled from ContactInfo where (roles&" . Contact::ROLE_PC . ")!=0"); $by_name_text = array(); $pctags = array("pc" => "pc"); while ($result && ($row = Contact::fetch($result))) { $pc[$row->contactId] = $row; if ($row->firstName || $row->lastName) { $name_text = Text::name_text($row); if (isset($by_name_text[$name_text])) { $row->nameAmbiguous = $by_name_text[$name_text]->nameAmbiguous = true; } $by_name_text[$name_text] = $row; } if ($row->contactTags) { foreach (explode(" ", $row->contactTags) as $t) { list($tag, $value) = TagInfo::split_index($t); if ($tag) { $pctags[strtolower($tag)] = $tag; } } } } uasort($pc, "Contact::compare"); ksort($pctags); $order = 0; foreach ($pc as $row) { $row->sort_position = $order; ++$order; } $PcMembersCache = array($Conf->setting("pc"), @$Opt["sortByLastName"], $pc, $pctags); } return $PcMembersCache[2]; }
require_once DOL_DOCUMENT_ROOT . "/core/lib/contact.lib.php"; $langs->load("companies"); $langs->load("other"); $id = GETPOST('id', 'int'); $action = GETPOST('action', 'alpha'); // Security check if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); /* * Action */ if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) { $ret = $object->fetch($id); // Note: Correct date should be completed with location to have exact GM time of birth. $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]); $object->birthday_alert = $_POST["birthday_alert"]; $result = $object->update_perso($id, $user); if ($result > 0) { $object->old_name = ''; $object->old_firstname = ''; } else { $error = $object->error; } } /* * View */ $now = dol_now();
* \ingroup societe */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/contact.lib.php'; require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $action = GETPOST('action'); $langs->load("companies"); // Security check $id = GETPOST('id', 'int'); if ($user->societe_id) { $id = $user->societe_id; } $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Contact($db); if ($id > 0) { $object->fetch($id); } $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* * View */ $title = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"); $form = new Form($db); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url);
/** * Charge le contact d'id $id dans this->contact * * @param int $contactid Id du contact * @return int <0 if KO, >0 if OK */ function fetch_contact($contactid) { require_once DOL_DOCUMENT_ROOT . "/contact/class/contact.class.php"; $contact = new Contact($this->db); $result = $contact->fetch($contactid); $this->contact = $contact; return $result; }
/** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { global $conf, $langs, $user, $hookmanager, $form; if (!is_object($form)) { $form = new Form($this->db); } $langs->load("other"); $langs->load("mails"); $hookmanager->initHooks(array('formmail')); $parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction); $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); if (!empty($reshook)) { return $hookmanager->resPrint; } else { $out = ''; // Define list of attached files $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($_SESSION["listofpaths"])) { $listofpaths = explode(';', $_SESSION["listofpaths"]); } if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } $out .= "\n<!-- Debut form mail -->\n"; if ($this->withform == 1) { $out .= '<form method="POST" name="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">' . "\n"; $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />'; } foreach ($this->param as $key => $value) { $out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n"; } $out .= '<table class="border" width="100%">' . "\n"; // Substitution array if (!empty($this->withsubstit)) { $out .= '<tr><td colspan="2">'; $help = ""; foreach ($this->substit as $key => $val) { $help .= $key . ' -> ' . $langs->trans($val) . '<br>'; } $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help); $out .= "</td></tr>\n"; } // From if (!empty($this->withfrom)) { if (!empty($this->withfromreadonly)) { $out .= '<input type="hidden" id="fromname" name="fromname" value="' . $this->fromname . '" />'; $out .= '<input type="hidden" id="frommail" name="frommail" value="' . $this->frommail . '" />'; $out .= '<tr><td width="180">' . $langs->trans("MailFrom") . '</td><td>'; if ($this->fromtype == 'user' && $this->fromid > 0) { $langs->load("users"); $fuser = new User($this->db); $fuser->fetch($this->fromid); $out .= $fuser->getNomUrl(1); } else { $out .= $this->fromname; } if ($this->frommail) { $out .= " <" . $this->frommail . ">"; } else { if ($this->fromtype) { $langs->load("errors"); $out .= '<font class="warning"> <' . $langs->trans("ErrorNoMailDefinedForThisUser") . '> </font>'; } } $out .= "</td></tr>\n"; $out .= "</td></tr>\n"; } else { $out .= "<tr><td>" . $langs->trans("MailFrom") . "</td><td>"; $out .= $langs->trans("Name") . ':<input type="text" id="fromname" name="fromname" size="32" value="' . $this->fromname . '" />'; $out .= ' '; $out .= $langs->trans("EMail") . ':<<input type="text" id="frommail" name="frommail" size="32" value="' . $this->frommail . '" />>'; $out .= "</td></tr>\n"; } } // Replyto if (!empty($this->withreplyto)) { if ($this->withreplytoreadonly) { $out .= '<input type="hidden" id="replyname" name="replyname" value="' . $this->replytoname . '" />'; $out .= '<input type="hidden" id="replymail" name="replymail" value="' . $this->replytomail . '" />'; $out .= "<tr><td>" . $langs->trans("MailReply") . "</td><td>" . $this->replytoname . ($this->replytomail ? " <" . $this->replytomail . ">" : ""); $out .= "</td></tr>\n"; } } // Errorsto if (!empty($this->witherrorsto)) { //if (! $this->errorstomail) $this->errorstomail=$this->frommail; $errorstomail = !empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail; if ($this->witherrorstoreadonly) { $out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= $errorstomail; $out .= "</td></tr>\n"; } else { $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= '<input size="30" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= "</td></tr>\n"; } } // To if (!empty($this->withto) || is_array($this->withto)) { $out .= '<tr><td width="180">'; if ($this->withtofree) { $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); } else { $out .= $langs->trans("MailTo"); } $out .= '</td><td>'; if ($this->withtoreadonly) { if (!empty($this->toname) && !empty($this->tomail)) { $out .= '<input type="hidden" id="toname" name="toname" value="' . $this->toname . '" />'; $out .= '<input type="hidden" id="tomail" name="tomail" value="' . $this->tomail . '" />'; if ($this->totype == 'thirdparty') { $soc = new Societe($this->db); $soc->fetch($this->toid); $out .= $soc->getNomUrl(1); } else { if ($this->totype == 'contact') { $contact = new Contact($this->db); $contact->fetch($this->toid); $out .= $contact->getNomUrl(1); } else { $out .= $this->toname; } } $out .= ' <' . $this->tomail . '>'; if ($this->withtofree) { $out .= '<br>' . $langs->trans("or") . ' <input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } } else { $out .= !is_array($this->withto) && !is_numeric($this->withto) ? $this->withto : ""; } } else { if (!empty($this->withtofree)) { $out .= '<input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } if (!empty($this->withto) && is_array($this->withto)) { if (!empty($this->withtofree)) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); } if (isset($this->withtosocid) && $this->withtosocid > 0) { $liste = array(); $soc = new Societe($this->db); $soc->fetch($this->withtosocid); foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; } if ($this->withtofree) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); } } $out .= "</td></tr>\n"; } // CC if (!empty($this->withtocc) || is_array($this->withtocc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if ($this->withtoccreadonly) { $out .= !is_array($this->withtocc) && !is_numeric($this->withtocc) ? $this->withtocc : ""; } else { $out .= '<input size="' . (is_array($this->withtocc) ? "30" : "60") . '" id="sendtocc" name="sendtocc" value="' . (!is_array($this->withtocc) && !is_numeric($this->withtocc) ? isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")) . '" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1); } } $out .= "</td></tr>\n"; } // CCC if (!empty($this->withtoccc) || is_array($this->withtoccc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if (!empty($this->withtocccreadonly)) { $out .= !is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? $this->withtoccc : ""; } else { $out .= '<input size="' . (is_array($this->withtoccc) ? "30" : "60") . '" id="sendtoccc" name="sendtoccc" value="' . (!is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")) . '" />'; if (!empty($this->withtoccc) && is_array($this->withtoccc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); } } //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); $out .= "</td></tr>\n"; } // Ask delivery receipt if (!empty($this->withdeliveryreceipt)) { $out .= '<tr><td width="180">' . $langs->trans("DeliveryReceipt") . '</td><td>'; if (!empty($this->withdeliveryreceiptreadonly)) { $out .= yn($this->withdeliveryreceipt); } else { $out .= $form->selectyesno('deliveryreceipt', isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : 0, 1); } $out .= "</td></tr>\n"; } // Topic if (!empty($this->withtopic)) { $this->withtopic = make_substitutions($this->withtopic, $this->substit); $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailTopic") . '</td>'; $out .= '<td>'; if ($this->withtopicreadonly) { $out .= $this->withtopic; $out .= '<input type="hidden" size="60" id="subject" name="subject" value="' . $this->withtopic . '" />'; } else { $out .= '<input type="text" size="60" id="subject" name="subject" value="' . (isset($_POST["subject"]) ? $_POST["subject"] : (is_numeric($this->withtopic) ? '' : $this->withtopic)) . '" />'; } $out .= "</td></tr>\n"; } // Attached files if (!empty($this->withfile)) { $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>'; $out .= '<td>'; if (is_numeric($this->withfile)) { // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; $out .= '<script type="text/javascript" language="javascript">'; $out .= 'jQuery(document).ready(function () {'; $out .= ' jQuery(".removedfile").click(function() {'; $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; $out .= ' });'; $out .= '})'; $out .= '</script>' . "\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '<div id="attachfile_' . $key . '">'; $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; if (!$this->withfilereadonly) { $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>'; } $out .= '<br></div>'; } } else { $out .= $langs->trans("NoAttachedFiles") . '<br>'; } if ($this->withfile == 2) { $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; $out .= ' '; $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />'; } } else { $out .= $this->withfile; } $out .= "</td></tr>\n"; } // Message if (!empty($this->withbody)) { $defaultmessage = ""; // TODO A partir du type, proposer liste de messages dans table llx_c_email_template if ($this->param["models"] == 'facture_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($this->param["models"] == 'facture_relance') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } elseif ($this->param["models"] == 'propal_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendProposal"); } elseif ($this->param["models"] == 'order_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendOrder"); } elseif ($this->param["models"] == 'order_supplier_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } elseif ($this->param["models"] == 'invoice_supplier_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } elseif ($this->param["models"] == 'shipping_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($this->param["models"] == 'fichinter_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($this->param["models"] == 'thirdparty') { $defaultmessage = $langs->transnoentities("PredefinedMailContentThirdparty"); } elseif (!is_numeric($this->withbody)) { $defaultmessage = $this->withbody; } // Complete substitution array if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) { require_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; $langs->load('paypal'); if ($this->param["models"] == 'order_send') { $url = getPaypalPaymentUrl(0, 'order', $this->substit['__ORDERREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } if ($this->param["models"] == 'facture_send') { $url = getPaypalPaymentUrl(0, 'invoice', $this->substit['__FACREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } } $defaultmessage = str_replace('\\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']); } else { if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } } if (isset($_POST["message"])) { $defaultmessage = $_POST["message"]; } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage); $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } $out .= '<tr>'; $out .= '<td width="180" valign="top">' . $langs->trans("MailText") . '</td>'; $out .= '<td>'; if ($this->withbodyreadonly) { $out .= nl2br($defaultmessage); $out .= '<input type="hidden" id="message" name="message" value="' . $defaultmessage . '" />'; } else { if (!isset($this->ckeditortoolbar)) { $this->ckeditortoolbar = 'dolibarr_notes'; } // Editor wysiwyg require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if ($this->withfckeditor == -1) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $this->withfckeditor = 1; } else { $this->withfckeditor = 0; } } $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, 72); $out .= $doleditor->Create(1); } $out .= "</td></tr>\n"; } if ($this->withform == 1 || $this->withform == -1) { $out .= '<tr><td align="center" colspan="2"><center>'; $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="' . $langs->trans("SendMail") . '"'; // Add a javascript test to avoid to forget to submit file before sending email if ($this->withfile == 2 && $conf->use_javascript_ajax) { $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\'' . dol_escape_js($langs->trans("FileWasNotUploaded")) . '\'); return false; } else { return true; }"'; } $out .= ' />'; if ($this->withcancel) { $out .= ' '; $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="' . $langs->trans("Cancel") . '" />'; } $out .= '</center></td></tr>' . "\n"; } $out .= '</table>' . "\n"; if ($this->withform == 1) { $out .= '</form>' . "\n"; } $out .= "<!-- Fin form mail -->\n"; return $out; } }
/** * Function to build a document on disk using the generic odt module. * * @param Project $object Object source to build document * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs, $srctemplatepath) { global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); return -1; } // Add odtgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; if (!is_object($outputlangs)) { $outputlangs = $langs; } $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("projects"); if ($conf->projet->dir_output) { // If $object is id instead of object if (!is_object($object)) { $id = $object; $object = new Project($this->db); $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } } $dir = $conf->projet->dir_output; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".odt"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); $newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref . '_' . $newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { $filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat; } else { $filename = $newfiletmp . '.' . $newfileformat; } $file = $dir . '/' . $filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; //print "conf->societe->dir_temp=".$conf->societe->dir_temp; dol_mkdir($conf->projet->dir_temp); $socobject = $object->thirdparty; // Make substitution $substitutionarray = array('__FROM_NAME__' => $this->emetteur->nom, '__FROM_EMAIL__' => $this->emetteur->email); complete_substitutions_array($substitutionarray, $langs, $object); // Open and load template require_once ODTPHP_PATH . 'odf.php'; try { $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->projet->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}')); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } // After construction $odfHandler->contentXml contains content and // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN lines --]*[!-- END lines --] //print html_entity_decode($odfHandler->__toString()); //print exit; // Make substitutions into odt of user info $tmparray = $this->get_substitutionarray_user($user, $outputlangs); foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { //var_dump($value);exit; if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } } else { $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { } } // Make substitutions into odt of mysoc $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); //var_dump($tmparray); exit; foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { //var_dump($value);exit; if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } } else { $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { } } // Make substitutions into odt of thirdparty $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } } else { $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { } } // Replace tags of object + external modules $tmparray = $this->get_substitutionarray_object($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } } else { $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { } } // Replace tags of lines for tasks try { $listlines = $odfHandler->setSegment('tasks'); $taskstatic = new Task($this->db); // Security check $socid = 0; if (!empty($object->fk_soc)) { $socid = $object->fk_soc; } $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0); foreach ($tasksarray as $task) { $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs); //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines"); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $taskobj = new Task($this->db); $taskobj->fetch($task->id); // Replace tags of lines for contacts task $sourcearray = array('internal', 'external'); $contact_arrray = array(); foreach ($sourcearray as $source) { $contact_temp = $taskobj->liste_contact(-1, $source); if (is_array($contact_temp) && count($contact_temp) > 0) { $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if (is_array($contact_arrray) && count($contact_arrray) > 0) { $listlinestaskres = $listlines->__get('tasksressources'); foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); $contact['socname'] = $mysoc->name; } elseif ($contact['source'] == 'external') { $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); $soc = new Societe($this->db); $soc->fetch($contact['socid']); $contact['socname'] = $soc->name; } $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlinestaskres->merge(); } } //Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; $sql .= ", u.lastname, u.firstname"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task_time as t"; $sql .= " , " . MAIN_DB_PREFIX . "user as u"; $sql .= " WHERE t.fk_task =" . $task->id; $sql .= " AND t.fk_user = u.rowid"; $sql .= " ORDER BY t.task_date DESC"; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $tasks = array(); $listlinestasktime = $listlines->__get('taskstimes'); while ($i < $num) { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { $row['fullcivname'] = ''; } $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlinestasktime->merge(); $i++; } $this->db->free($resql); } // Replace tags of project files $listtasksfiles = $listlines->__get('tasksfiles'); $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref) . '/' . dol_sanitizeFileName($task->ref); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); foreach ($tmparray as $key => $val) { try { $listtasksfiles->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listtasksfiles->merge(); } $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of project files try { $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts $sourcearray = array('internal', 'external'); $contact_arrray = array(); foreach ($sourcearray as $source) { $contact_temp = $object->liste_contact(-1, $source); if (is_array($contact_temp) && count($contact_temp) > 0) { $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if (is_array($contact_arrray) && count($contact_arrray) > 0) { try { $listlines = $odfHandler->setSegment('projectcontacts'); foreach ($contact_arrray as $contact) { if ($contact['source'] == 'internal') { $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); $contact['socname'] = $mysoc->name; } elseif ($contact['source'] == 'external') { $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); $soc = new Societe($this->db); $soc->fetch($contact['socid']); $contact['socname'] = $soc->name; } $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlines->merge(); } $odfHandler->mergeSegment($listlines); } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } } //List of referent $listofreferent = array('propal' => array('title' => "ListProposalsAssociatedProject", 'class' => 'Propal', 'table' => 'propal', 'test' => $conf->propal->enabled && $user->rights->propale->lire), 'order' => array('title' => "ListOrdersAssociatedProject", 'class' => 'Commande', 'table' => 'commande', 'test' => $conf->commande->enabled && $user->rights->commande->lire), 'invoice' => array('title' => "ListInvoicesAssociatedProject", 'class' => 'Facture', 'table' => 'facture', 'test' => $conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined' => array('title' => "ListPredefinedInvoicesAssociatedProject", 'class' => 'FactureRec', 'table' => 'facture_rec', 'test' => $conf->facture->enabled && $user->rights->facture->lire), 'order_supplier' => array('title' => "ListSupplierOrdersAssociatedProject", 'table' => 'commande_fournisseur', 'class' => 'CommandeFournisseur', 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'invoice_supplier' => array('title' => "ListSupplierInvoicesAssociatedProject", 'table' => 'facture_fourn', 'class' => 'FactureFournisseur', 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract' => array('title' => "ListContractAssociatedProject", 'class' => 'Contrat', 'table' => 'contrat', 'test' => $conf->contrat->enabled && $user->rights->contrat->lire), 'intervention' => array('title' => "ListFichinterAssociatedProject", 'class' => 'Fichinter', 'table' => 'fichinter', 'disableamount' => 1, 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'trip' => array('title' => "ListTripAssociatedProject", 'class' => 'Deplacement', 'table' => 'deplacement', 'disableamount' => 1, 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda' => array('title' => "ListActionsAssociatedProject", 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire)); //Insert reference try { $listlines = $odfHandler->setSegment('projectrefs'); foreach ($listofreferent as $keyref => $valueref) { $title = $valueref['title']; $tablename = $valueref['table']; $classname = $valueref['class']; $qualified = $valueref['test']; if ($qualified) { $elementarray = $object->get_element_list($keyref, $tablename); if (count($elementarray) > 0 && is_array($elementarray)) { $var = true; $total_ht = 0; $total_ttc = 0; $num = count($elementarray); for ($i = 0; $i < $num; $i++) { $ref_array = array(); $ref_array['type'] = $langs->trans($classname); $element = new $classname($this->db); $element->fetch($elementarray[$i]); $element->fetch_thirdparty(); //Ref object $ref_array['ref'] = $element->ref; //Date object $dateref = $element->date; if (empty($dateref)) { $dateref = $element->datep; } if (empty($dateref)) { $dateref = $element->date_contrat; } $ref_array['date'] = $dateref; //Soc object if (is_object($element->thirdparty)) { $ref_array['socname'] = $element->thirdparty->name; } else { $ref_array['socname'] = ''; } //Amount object if (empty($valueref['disableamount'])) { if (!empty($element->total_ht)) { $ref_array['amountht'] = $element->total_ht; $ref_array['amountttc'] = $element->total_ttc; } else { $ref_array['amountht'] = 0; $ref_array['amountttc'] = 0; } } else { $ref_array['amountht'] = ''; $ref_array['amountttc'] = ''; } $ref_array['status'] = $element->getLibStatut(0); $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs); foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { } catch (SegmentException $e) { } } $listlines->merge(); } } } $odfHandler->mergeSegment($listlines); } } catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated $tmparray = $outputlangs->get_translations_for_substitutions(); foreach ($tmparray as $key => $value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } catch (OdfException $e) { } } // Call the beforeODTSave hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } } else { try { $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error = $e->getMessage(); return -1; } } if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } $odfHandler = null; // Destroy object return 1; // Success } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } return -1; }
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers * * Following properties must be filled: * $object->actiontypecode (translation action code: AC_OTH, ...) * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact) * $object->socid * Optionnal: * $object->fk_element * $object->elementtype * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ function run_trigger($action, $object, $user, $langs, $conf) { $key = 'MAIN_AGENDA_ACTIONAUTO_' . $action; //dol_syslog("xxxxxxxxxxx".$key); if (empty($conf->agenda->enabled)) { return 0; } // Module not active, we do nothing if (empty($conf->global->{$key})) { return 0; } // Log events not enabled for this action $ok = 0; // Actions if ($action == 'COMPANY_CREATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); } $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); if ($object->prefix) { $object->actionmsg .= " (" . $object->prefix . ")"; } //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->socid = $object->id; $ok = 1; } elseif ($action == 'CONTRACT_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("contracts"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'FICHEINTER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("interventions"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; $ok = 1; } elseif ($action == 'FICHEINTER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("interventions"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; // Parameters $object->sendotid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'SHIPPING_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("sendings"); $langs->load("agenda"); $object->actiontypecode = 'AC_SHIP'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendotid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Amount") . ': ' . $object->last_subscription_amount; $object->actionmsg .= "\n" . $langs->transnoentities("Period") . ': ' . dol_print_date($object->last_subscription_date_start, 'day') . ' - ' . dol_print_date($object->last_subscription_date_end, 'day'); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } // If not found /* else { dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action."); return 0; } */ // Add entry in event table if ($ok) { $now = dol_now(); require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $contactforaction = new Contact($this->db); $societeforaction = new Societe($this->db); if ($object->sendtoid > 0) { $contactforaction->fetch($object->sendtoid); } if ($object->socid > 0) { $societeforaction->fetch($object->socid); } // Insertion action require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; $actioncomm->percentage = -1; // Not applicable $actioncomm->contact = $contactforaction; $actioncomm->societe = $societeforaction; $actioncomm->author = $user; // User saving action //$actioncomm->usertodo = $user; // User affected to action $actioncomm->userdone = $user; // User doing action $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; $ret = $actioncomm->add($user); // User qui saisit l'action if ($ret > 0) { return 1; } else { $error = "Failed to insert : " . $actioncomm->error . " "; $this->error = $error; dol_syslog("interface_modAgenda_ActionsAuto.class.php: " . $this->error, LOG_ERR); return -1; } } return 0; }
* \ingroup societe * \brief Onglet info d'un contact */ require '../main.inc.php'; 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 . '/core/lib/contact.lib.php'; $langs->load("companies"); // Security check $contactid = GETPOST("id", 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'contact', $contactid, 'socpeople&societe'); $contact = new Contact($db); /* * View */ $title = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"); llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); if ($contactid > 0) { $result = $contact->fetch($contactid, $user); $contact->info($contactid); $head = contact_prepare_head($contact); dol_fiche_head($head, 'info', $title, 0, 'contact'); // TODO Put here ref of card dol_print_object_info($contact); dol_fiche_end(); } llxFooter(); $db->close();
if (!empty($backtopage)) { header("Location: " . $backtopage); exit; } else { $action = ''; } } /* * View */ $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); if ($action == 'create') { $contact = new Contact($db); if (GETPOST("contactid")) { $result = $contact->fetch(GETPOST("contactid")); if ($result < 0) { dol_print_error($db, $contact->error); } } dol_set_focus("#label"); if (!empty($conf->use_javascript_ajax)) { print "\n" . '<script type="text/javascript">'; print '$(document).ready(function () { function setdatefields() { if ($("#fullday:checked").val() == null) { $(".fulldaystarthour").removeAttr("disabled"); $(".fulldaystartmin").removeAttr("disabled"); $(".fulldayendhour").removeAttr("disabled"); $(".fulldayendmin").removeAttr("disabled");
} else { print preg_replace('/./i', '*', $fuser->phenix_pass_crypted); } print '</td></tr>'; } // Company / Contact if ($conf->societe->enabled) { print '<tr><td width="25%" valign="top">' . $langs->trans("LinkToCompanyContact") . '</td>'; print '<td>'; if ($fuser->societe_id > 0) { $societe = new Societe($db); $societe->fetch($fuser->societe_id); print $societe->getNomUrl(1, ''); if ($fuser->contact_id) { $contact = new Contact($db); $contact->fetch($fuser->contact_id); print ' / <a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $fuser->contact_id . '">' . img_object($langs->trans("ShowContact"), 'contact') . ' ' . dol_trunc($contact->getFullName($langs), 32) . '</a>'; } } else { print $langs->trans("ThisUserIsNot"); } print '</td>'; print "</tr>\n"; } // Module Adherent if ($conf->adherent->enabled) { $langs->load("members"); print '<tr><td width="25%" valign="top">' . $langs->trans("LinkedToDolibarrMember") . '</td>'; print '<td>'; if ($fuser->fk_member) { $adh = new Adherent($db);
} else { if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'societe'; } else { if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'member'; } else { if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; } } } } } $result = $object->del_type($tmpobject, $elementtype); if ($result < 0) { dol_print_error('', $object->error); } } if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($user) >= 0) { header("Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type); exit;
/** * Show event of a particular day * * @param DoliDB $db Database handler * @param int $day Day * @param int $month Month * @param int $year Year * @param int $monthshown Current month shown in calendar view * @param string $style Style to use for this day * @param array &$eventarray Array of events * @param int $maxprint Nb of actions to show each day on month view (0 means no limit) * @param int $maxnbofchar Nb of characters to show for event line * @param string $newparam Parameters on current URL * @param int $showinfo Add extended information (used by day view) * @param int $minheight Minimum height for each event. 60px by default. * @return void */ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60) { global $user, $conf, $langs; global $filter, $filtera, $filtert, $filterd, $status; global $theme_datacolor; global $cachethirdparties, $cachecontacts; print '<div id="dayevent_' . sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day) . '" class="dayevent">' . "\n"; $curtime = dol_mktime(0, 0, 0, $month, $day, $year); print '<table class="nobordernopadding" width="100%">'; print '<tr style="background: #EEEEEE"><td align="left" nowrap="nowrap">'; print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?'; print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year; print $newparam; //.'&month='.$month.'&year='.$year; print '">'; if ($showinfo) { print dol_print_date($curtime, 'daytext'); } else { print dol_print_date($curtime, '%d'); } print '</a>'; print '</td><td align="right" nowrap="nowrap">'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { //$param='month='.$monthshown.'&year='.$year; $hourminsec = '100000'; print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&datep=' . sprintf("%04d%02d%02d", $year, $month, $day) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '">'; print img_picto($langs->trans("NewAction"), 'edit_add.png'); print '</a>'; } print '</td></tr>'; print '<tr height="' . $minheight . '"><td valign="top" colspan="2" nowrap="nowrap">'; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); $i = 0; $nummytasks = 0; $numother = 0; $numbirthday = 0; $numical = 0; $numicals = array(); $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day); foreach ($eventarray as $daykey => $notused) { $annee = date('Y', $daykey); $mois = date('m', $daykey); $jour = date('d', $daykey); if ($day == $jour && $month == $mois && $year == $annee) { foreach ($eventarray[$daykey] as $index => $event) { if ($i < $maxprint || $maxprint == 0 || !empty($conf->global->MAIN_JS_SWITCH_AGENDA)) { $ponct = $event->date_start_in_calendar == $event->date_end_in_calendar; // Define $color and $cssclass of event $color = -1; $cssclass = ''; $colorindex = -1; if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) { $nummytasks++; $colorindex = 1; $cssclass = 'family_mytasks'; } else { if ($event->type_code == 'ICALEVENT') { $numical++; $numicals[dol_string_nospecial($event->icalname)]++; $color = $event->icalcolor; $cssclass = $event->icalname ? 'family_' . dol_string_nospecial($event->icalname) : 'family_other'; } else { if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday'; } else { $numother++; $colorindex = 2; $cssclass = 'family_other'; } } } if ($color == -1) { $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } $cssclass = $cssclass . ' ' . $cssclass . '_day_' . $ymd; // Show rect of event print '<div id="event_' . $ymd . '_' . $i . '" class="event ' . $cssclass . '">'; print '<table class="cal_event" style="background: #' . $color . '; -moz-border-radius:4px;" width="100%"><tr>'; print '<td nowrap="nowrap">'; if ($event->type_code == 'BIRTHDAY') { print $event->getNomUrl(1, $maxnbofchar, 'cal_event', 'birthday', 'contact'); } if ($event->type_code != 'BIRTHDAY') { // Picto if (empty($event->fulldayevent)) { //print $event->getNomUrl(2).' '; } // Date if (empty($event->fulldayevent)) { //print '<strong>'; $daterange = ''; // Show hours (start ... end) $tmpyearstart = date('Y', $event->date_start_in_calendar); $tmpmonthstart = date('m', $event->date_start_in_calendar); $tmpdaystart = date('d', $event->date_start_in_calendar); $tmpyearend = date('Y', $event->date_end_in_calendar); $tmpmonthend = date('m', $event->date_end_in_calendar); $tmpdayend = date('d', $event->date_end_in_calendar); // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { $daterange .= '-'; } //else //print '...'; } } if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { $daterange .= '...'; } } // Hour end if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); } } //print $daterange; if ($event->type_code != 'ICALEVENT') { $savlabel = $event->libelle; $event->libelle = $daterange; print $event->getNomUrl(0); $event->libelle = $savlabel; } else { print $daterange; } //print '</strong> '; print "<br>\n"; } else { if ($showinfo) { print $langs->trans("EventOnFullDay") . "<br>\n"; } } // Show title if ($event->type_code == 'ICALEVENT') { print dol_trunc($event->libelle, $maxnbofchar); } else { print $event->getNomUrl(0, $maxnbofchar, 'cal_event'); } if ($event->type_code == 'ICALEVENT') { print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')'; } // If action related to company / contact $linerelatedto = ''; $length = 16; if (!empty($event->societe->id) && !empty($event->contact->id)) { $length = round($length / 2); } if (!empty($event->societe->id) && $event->societe->id > 0) { if (!isset($cachethirdparties[$event->societe->id]) || !is_object($cachethirdparties[$event->societe->id])) { $thirdparty = new Societe($db); $thirdparty->fetch($event->societe->id); $cachethirdparties[$event->societe->id] = $thirdparty; } else { $thirdparty = $cachethirdparties[$event->societe->id]; } $linerelatedto .= $thirdparty->getNomUrl(1, '', $length); } if (!empty($event->contact->id) && $event->contact->id > 0) { if (!is_object($cachecontacts[$event->contact->id])) { $contact = new Contact($db); $contact->fetch($event->contact->id); $cachecontacts[$event->contact->id] = $contact; } else { $contact = $cachecontacts[$event->contact->id]; } if ($linerelatedto) { $linerelatedto .= ' / '; } $linerelatedto .= $contact->getNomUrl(1, '', $length); } if ($linerelatedto) { print '<br>' . $linerelatedto; } } // Show location if ($showinfo) { if ($event->location) { print '<br>'; print $langs->trans("Location") . ': ' . $event->location; } } print '</td>'; // Status - Percent print '<td align="right" nowrap="nowrap">'; if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { print $event->getLibStatut(3, 1); } else { print ' '; } print '</td></tr></table>'; print '</div>'; $i++; } else { print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?maxprint=0&month=' . $monthshown . '&year=' . $year; print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : ''); print ($filtera ? '&filtera=' . $filtera : '') . ($filtert ? '&filtert=' . $filtert : '') . ($filterd ? '&filterd=' . $filterd : ''); print '">' . img_picto("all", "1downarrow_selected.png") . ' ...'; print ' +' . (count($eventarray[$daykey]) - $maxprint); print '</a>'; break; //$ok=false; // To avoid to show twice the link } } break; } } if (!$i) { print ' '; } if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>'; //print ' +'.(count($eventarray[$daykey])-$maxprint); print '<script type="text/javascript">' . "\n"; print 'jQuery(document).ready(function () {' . "\n"; print 'jQuery("#more_' . $ymd . '").click(function() { reinit_day_' . $ymd . '(); });' . "\n"; print 'function reinit_day_' . $ymd . '() {' . "\n"; print 'var nb=0;' . "\n"; // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached print 'jQuery(".family_mytasks_day_' . $ymd . '").toggle();'; print '}' . "\n"; print '});' . "\n"; print '</script>' . "\n"; } print '</td></tr>'; print '</table>'; print '</div>' . "\n"; }
require_once DOL_DOCUMENT_ROOT . '/core/lib/contact.lib.php'; $langs->load("companies"); // Security check $id = GETPOST('id', 'int'); if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); /* * View */ $title = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"); llxHeader('', $title, 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'); $form = new Form($db); $contact = new Contact($db); $contact->fetch($id, $user); $head = contact_prepare_head($contact); dol_fiche_head($head, 'exportimport', $title, 0, 'contact'); /* * Fiche en mode visu */ print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/contact/list.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="3">'; print $form->showrefnav($contact, 'id', $linkback); print '</td></tr>'; // Name print '<tr><td width="20%">' . $langs->trans("Lastname") . ' / ' . $langs->trans("Label") . '</td><td>' . $contact->lastname . '</td>'; print '<td width="20%">' . $langs->trans("Firstname") . '</td><td width="25%">' . $contact->firstname . '</td></tr>'; // Company
/** * Show event of a particular day * @param $db Database handler * @param $day Day * @param $month Month * @param $year Year * @param $monthshown Current month shown in calendar view * @param $style Style to use for this day * @param $eventarray Array of events * @param $maxPrint Nb of actions to show each day on month view (0 means non limit) * @param $maxnbofchar Nb of characters to show for event line * @param $newparam Parameters on current URL * @param $showinfo Add extended information (used by day view) * @param $minheight Minimum height for each event. 60px by default. */ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxPrint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60) { global $user, $conf, $langs; global $filter, $filtera, $filtert, $filterd, $status; global $theme_datacolor; global $cachethirdparties, $cachecontacts; if ($_GET["maxprint"] == 'on') $maxPrint=0; // Force to remove limits print '<div id="dayevent_'.sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day).'" class="dayevent">'."\n"; $curtime = dol_mktime (0, 0, 0, $month, $day, $year); print '<table class="nobordernopadding" width="100%">'; print '<tr style="background: #EEEEEE"><td align="left" nowrap="nowrap">'; print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?'; print 'action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; print $newparam; //.'&month='.$month.'&year='.$year; print '">'; if ($showinfo) print dol_print_date($curtime,'daytext'); else print dol_print_date($curtime,'%d'); print '</a>'; print '</td><td align="right" nowrap="nowrap">'; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { //$param='month='.$monthshown.'&year='.$year; $hourminsec='100000'; print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&datep='.sprintf("%04d%02d%02d",$year,$month,$day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">'; print img_picto($langs->trans("NewAction"),'edit_add.png'); print '</a>'; } print '</td></tr>'; print '<tr height="'.$minheight.'"><td valign="top" colspan="2" nowrap="nowrap">'; //$curtime = dol_mktime (0, 0, 0, $month, $day, $year); $i=0; foreach ($eventarray as $daykey => $notused) { $annee = date('Y',$daykey); $mois = date('m',$daykey); $jour = date('d',$daykey); if ($day==$jour && $month==$mois && $year==$annee) { foreach ($eventarray[$daykey] as $index => $event) { if ($i < $maxPrint || $maxPrint == 0) { $ponct=($event->date_start_in_calendar == $event->date_end_in_calendar); // Show rect of event $colorindex=0; if ($event->author->id == $user->id || $event->usertodo->id == $user->id || $event->userdone->id == $user->id) $colorindex=1; if ($event->type_code == 'BIRTHDAY') $colorindex=2; if ($event->type_code == 'ICALEVENT') $color=$event->icalcolor; else $color=sprintf("%02x%02x%02x",$theme_datacolor[$colorindex][0],$theme_datacolor[$colorindex][1],$theme_datacolor[$colorindex][2]); //print "x".$color; print '<div id="event_'.sprintf("%04d",$annee).sprintf("%02d",$mois).sprintf("%02d",$jour).'_'.$i.'" class="event">'; print '<table class="cal_event" style="background: #'.$color.'; -moz-border-radius:4px; " width="100%"><tr>'; print '<td nowrap="nowrap">'; if ($event->type_code == 'BIRTHDAY') // It's a birthday { print $event->getNomUrl(1,$maxnbofchar,'cal_event','birthday','contact'); } if ($event->type_code != 'BIRTHDAY') { // Picto if (empty($event->fulldayevent)) { //print $event->getNomUrl(2).' '; } // Date if (empty($event->fulldayevent)) { //print '<strong>'; $daterange=''; // Show hours (start ... end) $tmpyearstart = date('Y',$event->date_start_in_calendar); $tmpmonthstart = date('m',$event->date_start_in_calendar); $tmpdaystart = date('d',$event->date_start_in_calendar); $tmpyearend = date('Y',$event->date_end_in_calendar); $tmpmonthend = date('m',$event->date_end_in_calendar); $tmpdayend = date('d',$event->date_end_in_calendar); // Hour start if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { $daterange.=dol_print_date($event->date_start_in_calendar,'%H:%M'); if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) $daterange.='-'; //else //print '...'; } } if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearstart != $tmpyearend || $tmpmonthstart != $tmpmonthend || $tmpdaystart != $tmpdayend) { $daterange.='...'; } } // Hour end if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) $daterange.=dol_print_date($event->date_end_in_calendar,'%H:%M'); } //print $daterange; if ($event->type_code != 'ICALEVENT') { $savlabel=$event->libelle; $event->libelle=$daterange; print $event->getNomUrl(0); $event->libelle=$savlabel; } else { print $daterange; } //print '</strong> '; print "<br>\n"; } else { if ($showinfo) { print $langs->trans("EventOnFullDay")."<br>\n"; } } // Show title if ($event->type_code == 'ICALEVENT') print dol_trunc($event->libelle,$maxnbofchar); else print $event->getNomUrl(0,$maxnbofchar,'cal_event'); if ($event->type_code == 'ICALEVENT') print '<br>('.dol_trunc($event->icalname,$maxnbofchar).')'; // If action related to company / contact $linerelatedto='';$length=16; if (! empty($event->societe->id) && ! empty($event->contact->id)) $length=round($length/2); if (! empty($event->societe->id) && $event->societe->id > 0) { if (! is_object($cachethirdparties[$event->societe->id])) { $thirdparty=new Societe($db); $thirdparty->fetch($event->societe->id); $cachethirdparties[$event->societe->id]=$thirdparty; } else $thirdparty=$cachethirdparties[$event->societe->id]; $linerelatedto.=$thirdparty->getNomUrl(1,'',$length); } if (! empty($event->contact->id) && $event->contact->id > 0) { if (! is_object($cachecontacts[$event->contact->id])) { $contact=new Contact($db); $contact->fetch($event->contact->id); $cachecontacts[$event->contact->id]=$contact; } else $contact=$cachecontacts[$event->contact->id]; if ($linerelatedto) $linerelatedto.=' / '; $linerelatedto.=$contact->getNomUrl(1,'',$length); } if ($linerelatedto) print '<br>'.$linerelatedto; } // Show location if ($showinfo) { if ($event->location) { print '<br>'; print $langs->trans("Location").': '.$event->location; } } print '</td>'; // Status - Percent print '<td align="right" nowrap="nowrap">'; if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') print $event->getLibStatut(3,1); else print ' '; print '</td></tr></table>'; print '</div>'; $i++; } else { print '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?maxprint=on&month='.$monthshown.'&year='.$year; print ($status?'&status='.$status:'').($filter?'&filter='.$filter:''); print ($filtera?'&filtera='.$filtera:'').($filtert?'&filtert='.$filtert:'').($filterd?'&filterd='.$filterd:''); print '">'.img_picto("all","1downarrow_selected.png").' ...'; print ' +'.(sizeof($eventarray[$daykey])-$maxPrint); print '</a>'; break; //$ok=false; // To avoid to show twice the link } } break; } } if (! $i) print ' '; print '</td></tr>'; print '</table>'; print '</div>'."\n"; }