/** * Load data into info_box_contents array to show array later. * * @param int $max of records to load * * @return void */ public function loadBox($max = 5) { global $conf, $user, $langs, $db; $this->max = $max; dol_include_once('/lead/class/lead.class.php'); $lead = new Lead($db); $lead->fetch_all('DESC', 't.date_closure', $max, 0, array('t.date_closure<' => dol_now())); $text = $langs->trans("LeadLate", $max); $this->info_box_head = array('text' => $text, 'limit' => dol_strlen($text)); $i = 0; foreach ($lead->lines as $line) { // FIXME: line is an array, not an object $line->fetch_thirdparty(); // Ref $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $line->ref, 'url' => dol_buildpath('/lead/lead/card.php', 1) . '?id=' . $line->id); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($line->thirdparty->name, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $line->fk_soc); // Amount Guess $this->info_box_contents[$i][4] = array('td' => 'align="left"', 'text' => price($line->amount_prosp, 'HTML') . $langs->getCurrencySymbol($conf->currency)); // Amount real $this->info_box_contents[$i][5] = array('td' => 'align="left"', 'text' => $line->getRealAmount() . $langs->getCurrencySymbol($conf->currency)); $i++; } }
function llxHeader($head = '', $title='', $help_url='', $morehtml='') { global $conf,$langs,$user; $langs->load("ftp"); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers $menu = new Menu(); $MAXFTP=20; $i=1; while ($i <= $MAXFTP) { $paramkey='FTP_NAME_'.$i; //print $paramkey; if (! empty($conf->global->$paramkey)) { $link="/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i; $menu->add($link, dol_trunc($conf->global->$paramkey,24)); } $i++; } left_menu($menu->liste, $help_url, $morehtml, '', 1); main_area(); }
/** * Load data for box to show them later * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; $now = dol_now(); $this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max)); if ($user->rights->contrat->lire) { // Select contracts with at least one expired service $sql = "SELECT "; $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat,"; $sql .= " s.nom as name, s.rowid as socid,"; $sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services"; $sql .= " FROM " . MAIN_DB_PREFIX . "contrat as c, " . MAIN_DB_PREFIX . "societe s, " . MAIN_DB_PREFIX . "contratdet as cd"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '" . $db->idate($now) . "'"; $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; if ($user->societe_id) { $sql .= ' AND c.fk_soc = ' . $user->societe_id; } if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, s.nom, s.rowid"; $sql .= " ORDER BY date_line ASC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $late = ''; $objp = $db->fetch_object($resql); $dateline = $db->jdate($objp->date_line); if ($dateline + $conf->contrat->services->expires->warning_delay < $now) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/contrat/card.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref ? $objp->ref : $objp->rowid, 'url' => DOL_URL_ROOT . "/contrat/card.php?id=" . $objp->rowid); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->name, 40), 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="center"', 'text' => dol_print_date($dateline, 'day'), 'text2' => $late); $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => $objp->nb_services); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoExpiredServices")); } $db->free($resql); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
/** * Return list of social contributions. * Use mysoc->country_id or mysoc->country_code so they must be defined. * * @param string $selected Preselected type * @param string $htmlname Name of field in form * @param int $useempty Set to 1 if we want an empty value * @param int $maxlen Max length of text in combo box * @param int $help Add or not the admin help picto * @return void */ function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1) { global $db, $langs, $user, $mysoc; if (empty($mysoc->country_id) && empty($mysoc->country_code)) { dol_print_error('', 'Call to select_type_socialcontrib with mysoc country not yet defined'); exit; } if (!empty($mysoc->country_id)) { $sql = "SELECT c.id, c.libelle as type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales as c"; $sql .= " WHERE c.active = 1"; $sql .= " AND c.fk_pays = " . $mysoc->country_id; $sql .= " ORDER BY c.libelle ASC"; } else { $sql = "SELECT c.id, c.libelle as type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales as c, " . MAIN_DB_PREFIX . "c_country as co"; $sql .= " WHERE c.active = 1 AND c.fk_pays = co.rowid"; $sql .= " AND co.code = '" . $mysoc->country_code . "'"; $sql .= " ORDER BY c.libelle ASC"; } dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { print '<select class="flat" name="' . $htmlname . '">'; $i = 0; if ($useempty) { print '<option value="0"> </option>'; } while ($i < $num) { $obj = $db->fetch_object($resql); print '<option value="' . $obj->id . '"'; if ($obj->id == $selected) { print ' selected="selected"'; } print '>' . dol_trunc($obj->type, $maxlen); $i++; } print '</select>'; if ($user->admin && $help) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } } else { print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code); } } else { dol_print_error($db, $db->lasterror()); } }
/** * Add area with bookmarks in menu * * @param DoliDb $aDb Database handler * @param Translate $aLangs Object lang * @return string */ function printBookmarksList($aDb, $aLangs) { global $conf, $user; $db = $aDb; $langs = $aLangs; require_once DOL_DOCUMENT_ROOT . '/bookmarks/class/bookmark.class.php'; if (!isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) { $conf->global->BOOKMARKS_SHOW_IN_MENU = 5; } $bookm = new Bookmark($db); $langs->load("bookmarks"); $url = $_SERVER["PHP_SELF"] . (!empty($_SERVER["QUERY_STRING"]) ? '?' . $_SERVER["QUERY_STRING"] : ''); $ret = ''; // Menu bookmark $ret .= '<div class="menu_titre">'; $ret .= '<table class="nobordernopadding" width="100%" summary="bookmarkstable"><tr><td>'; $ret .= '<a class="vmenu" href="' . DOL_URL_ROOT . '/bookmarks/liste.php">' . $langs->trans('Bookmarks') . '</a>'; $ret .= '</td><td align="right">'; if ($user->rights->bookmark->creer) { $ret .= '<a class="vsmenu" href="' . DOL_URL_ROOT . '/bookmarks/fiche.php?action=create&urlsource=' . urlencode($url) . '&url=' . urlencode($url) . '">'; //$ret.=img_picto($langs->trans('AddThisPageToBookmarks'),'edit_add').' '; $ret .= img_object($langs->trans('AddThisPageToBookmarks'), 'bookmark'); $ret .= '</a>'; } $ret .= '</td></tr></table>'; $ret .= '</div>'; $ret .= '<div class="menu_top"></div>' . "\n"; // Menu with all bookmarks if (!empty($conf->global->BOOKMARKS_SHOW_IN_MENU)) { $sql = "SELECT rowid, title, url, target FROM " . MAIN_DB_PREFIX . "bookmark"; $sql .= " WHERE (fk_user = "******" OR fk_user is NULL OR fk_user = 0)"; $sql .= " AND entity = " . $conf->entity; $sql .= " ORDER BY position"; if ($resql = $db->query($sql)) { $i = 0; while ($i < $conf->global->BOOKMARKS_SHOW_IN_MENU && ($obj = $db->fetch_object($resql))) { $ret .= '<div class="menu_contenu"><a class="vsmenu" title="' . $obj->title . '" href="' . $obj->url . '"' . ($obj->target == 1 ? ' target="_blank"' : '') . '>'; $ret .= ' ' . img_object('', 'bookmark') . ' '; $ret .= dol_trunc($obj->title, 20) . '</a><br></div>'; $i++; } } else { dol_print_error($db); } } $ret .= '<div class="menu_end"></div>'; return $ret; }
$bordereaustatic = new RemiseCheque($db); $bordereaustatic->id = $objp->fk_bordereau; $label .= ' ' . $bordereaustatic->getNomUrl(2); } print $label; print "</td>\n"; // Num print '<td class="nowrap">' . ($objp->num_chq ? $objp->num_chq : "") . "</td>\n"; // Description print '<td>'; // Show generic description if (preg_match('/^\\((.*)\\)$/i', $objp->label, $reg)) { // Generic description because between (). We show it after translating. print $langs->trans($reg[1]); } else { print dol_trunc($objp->label, 60); } // Add links after description $links = $object->get_url($objp->rowid); foreach ($links as $key => $val) { if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $paymentstatic->ref = $links[$key]['url_id']; print ' ' . $paymentstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_supplier') { $paymentsupplierstatic->id = $links[$key]['url_id']; $paymentsupplierstatic->ref = $links[$key]['url_id']; print ' ' . $paymentsupplierstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_sc') { print '<a href="' . DOL_URL_ROOT . '/compta/payment_sc/card.php?id=' . $links[$key]['url_id'] . '">'; print ' ' . img_object($langs->trans('ShowPayment'), 'payment') . ' ';
/** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option 'withproject' or '' * @param string $mode Mode 'task', 'time', 'contact', 'note', document' define page to link to. * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep Separator between ref and label if option addlabel is set * @return string Chaine avec URL */ function getNomUrl($withpicto = 0, $option = '', $mode = 'task', $addlabel = 0, $sep = ' - ') { global $langs; $result = ''; $label = '<u>' . $langs->trans("ShowTask") . '</u>'; if (!empty($this->ref)) { $label .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; } if (!empty($this->label)) { $label .= '<br><b>' . $langs->trans('LabelTask') . ':</b> ' . $this->label; } if ($this->date_start || $this->date_end) { $label .= "<br>" . get_date_range($this->date_start, $this->date_end, '', $langs, 0); } $linkclose = '" title="' . dol_escape_htmltag($label, 1) . '" class="classfortooltip">'; $link = '<a href="' . DOL_URL_ROOT . '/projet/tasks/' . $mode . '.php?id=' . $this->id . ($option == 'withproject' ? '&withproject=1' : '') . $linkclose; $linkend = '</a>'; $picto = 'projecttask'; if ($withpicto) { $result .= $link . img_object($label, $picto, 'class="classfortooltip"') . $linkend; } if ($withpicto && $withpicto != 2) { $result .= ' '; } if ($withpicto != 2) { $result .= $link . $this->ref . $linkend . ($addlabel && $this->label ? $sep . dol_trunc($this->label, $addlabel > 1 ? $addlabel : 0) : ''); } return $result; }
/** * Build an input field used to filter the query * * @param string $TypeField Type of Field to filter * @param string $NameField Name of the field to filter * @param string $ValueField Initial value of the field to filter * @return string html string of the input field ex : "<input type=text name=... value=...>" */ function build_filterField($TypeField, $NameField, $ValueField) { $szFilterField = ''; $InfoFieldList = explode(":", $TypeField); // build the input field on depend of the type of file switch ($InfoFieldList[0]) { case 'Text': case 'Date': case 'Duree': case 'Numeric': $szFilterField = '<input type="text" name=' . $NameField . " value='" . $ValueField . "'>"; break; case 'Boolean': $szFilterField = '<select name="' . $NameField . '" class="flat">'; $szFilterField .= '<option '; if ($ValueField == '') { $szFilterField .= ' selected '; } $szFilterField .= ' value=""> </option>'; $szFilterField .= '<option '; if ($ValueField == 'yes') { $szFilterField .= ' selected '; } $szFilterField .= ' value="yes">' . yn(1) . '</option>'; $szFilterField .= '<option '; if ($ValueField == 'no') { $szFilterField .= ' selected '; } $szFilterField .= ' value="no">' . yn(0) . '</option>'; $szFilterField .= "</select>"; break; case 'List': // 0 : Type du champ // 1 : Nom de la table // 2 : Nom du champ contenant le libelle // 3 : Nom du champ contenant la cle (si different de rowid) if (count($InfoFieldList) == 4) { $keyList = $InfoFieldList[3]; } else { $keyList = 'rowid'; } $sql = 'SELECT ' . $keyList . ' as rowid, ' . $InfoFieldList[2]; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[1]; $resql = $this->db->query($sql); if ($resql) { $szFilterField = '<select class="flat" name="' . $NameField . '">'; $szFilterField .= '<option value="0"> </option>'; $num = $this->db->num_rows($resql); $i = 0; if ($num) { while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj->{$InfoFieldList}[2] == '-') { // Discard entry '-' $i++; continue; } $labeltoshow = dol_trunc($obj->{$InfoFieldList}[2], 18); if (!empty($ValueField) && $ValueField == $obj->rowid) { $szFilterField .= '<option value="' . $obj->rowid . '" selected="selected">' . $labeltoshow . '</option>'; } else { $szFilterField .= '<option value="' . $obj->rowid . '" >' . $labeltoshow . '</option>'; } $i++; } } $szFilterField .= "</select>"; $this->db->free(); } break; } return $szFilterField; }
if ($obj->pid) { $productstatic->id = $obj->pid; $productstatic->type = $obj->ptype; $productstatic->ref = $obj->pref; $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); print $obj->label ? ' - ' . dol_trunc($obj->label, 16) : ''; if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) { print '<br>' . dol_nl2br($obj->description); } } else { if ($obj->type == 0) { print img_object($obj->description, 'product') . dol_trunc($obj->description, 20); } if ($obj->type == 1) { print img_object($obj->description, 'service') . dol_trunc($obj->description, 20); } } print '</td>'; // Third party print '<td>'; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->client = 1; print $companystatic->getNomUrl(1, 'customer', 28); print '</td>'; // Start date if ($mode == "0") { print '<td align="center">'; print $obj->date_ouverture_prevue ? dol_print_date($db->jdate($obj->date_ouverture_prevue)) : ' '; if ($db->jdate($obj->date_ouverture_prevue) && $db->jdate($obj->date_ouverture_prevue) < $now - $conf->contrat->services->inactifs->warning_delay) {
while ($i < $num) { $objp = $db->fetch_object($result); $var=!$var; print "<tr $bc[$var]>"; $classname = "impayee"; print '<td nowrap>'; $facturestatic->id=$objp->facid; $facturestatic->ref=$objp->ref; print $facturestatic->getNomUrl(1); print "</td>\n"; print "<td nowrap>".dol_trunc($objp->facnumber,12)."</td>\n"; print "<td nowrap align=\"center\">".dol_print_date($db->jdate($objp->df))."</td>\n"; print "<td nowrap align=\"center\">".dol_print_date($db->jdate($objp->datelimite)); if ($db->jdate($objp->datelimite) < ($now - $conf->facture->fournisseur->warning_delay) && ! $objp->paye && $objp->fk_statut == 1) print img_warning($langs->trans("Late")); print "</td>\n"; print '<td>'; $companystatic->id=$objp->socid; $companystatic->nom=$objp->nom; print $companystatic->getNomUrl(1,'supplier',32); print '</td>'; print "<td align=\"right\">".price($objp->total_ht)."</td>"; print "<td align=\"right\">".price($objp->total_ttc)."</td>"; print "<td align=\"right\">".price($objp->am)."</td>";
print '<tr ' . $bc[$var] . '>'; // Ref if (!empty($arrayfields['p.ref']['checked'])) { print '<td class="nowrap">'; print $product_static->getNomUrl(1, '', 24); print "</td>\n"; } // Ref supplier if (!empty($arrayfields['pfp.ref_fourn']['checked'])) { print '<td class="nowrap">'; print $product_static->getNomUrl(1, '', 24); print "</td>\n"; } // Label if (!empty($arrayfields['p.label']['checked'])) { print '<td>' . dol_trunc($objp->label, 40) . '</td>'; } // Barcode if (!empty($arrayfields['p.barcode']['checked'])) { print '<td>' . $objp->barcode . '</td>'; } // Duration if (!empty($arrayfields['p.duration']['checked'])) { print '<td align="center">'; if (preg_match('/([0-9]+)[a-z]/i', $objp->duration)) { if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { print $regs[1] . ' ' . $langs->trans("DurationYear"); } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { print $regs[1] . ' ' . $langs->trans("DurationMonth"); } elseif (preg_match('/([0-9]+)w/i', $objp->duration, $regs)) { print $regs[1] . ' ' . $langs->trans("DurationWeek");
print "</tr>\n"; $i = 1; $var = false; while ($objp = $db->fetch_object($resql)) { $account_id = $objp->bid; if (!isset($accounts[$objp->bid])) { $accounts[$objp->bid] = 0; } $accounts[$objp->bid] += 1; print "<tr " . $bc[$var] . ">"; print '<td align="center">' . $i . '</td>'; print '<td align="center">' . dol_print_date($db->jdate($objp->date), 'day') . '</td>'; // Date operation print '<td align="center">' . ($objp->num_chq ? $objp->num_chq : ' ') . '</td>'; print '<td>' . dol_trunc($objp->emetteur, 24) . '</td>'; print '<td>' . dol_trunc($objp->banque, 24) . '</td>'; print '<td align="right">' . price($objp->amount) . '</td>'; print '<td align="center">'; $accountlinestatic->rowid = $objp->rowid; if ($accountlinestatic->rowid) { print $accountlinestatic->getNomUrl(1); } else { print ' '; } print '</td>'; if ($object->statut == 0) { print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=remove&lineid=' . $objp->rowid . '">' . img_delete() . '</a></td>'; } else { print '<td> </td>'; } print '</tr>';
if ($resql) { print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td colspan="2">' . $langs->trans("DraftOrders") . '</td></tr>'; $langs->load("orders"); $num = $db->num_rows($resql); if ($num) { $i = 0; $var = True; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($resql); print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; print "<a href=\"card.php?id=" . $obj->rowid . "\">" . img_object($langs->trans("ShowOrder"), "order") . ' ' . $obj->ref . "</a></td>"; print '<td><a href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $obj->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . dol_trunc($obj->name, 24) . '</a></td></tr>'; $i++; } } print "</table><br>"; } } /* * List of users allowed */ $sql = "SELECT u.rowid, u.lastname, u.firstname"; $sql .= " FROM " . MAIN_DB_PREFIX . "user as u,"; $sql .= " " . MAIN_DB_PREFIX . "user_rights as ur"; $sql .= ", " . MAIN_DB_PREFIX . "rights_def as rd"; $sql .= " WHERE u.rowid = ur.fk_user"; $sql .= " AND (u.entity IN (0," . $conf->entity . ")";
print '<td class="nobordernopadding" nowrap="nowrap">'; print $propalstatic->getNomUrl(1); print '</td>'; print '<td width="18" class="nobordernopadding" nowrap="nowrap">'; if ($db->jdate($obj->dp) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print '</td>'; print '<td width="16" align="center" class="nobordernopadding">'; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print '</td></tr></table>'; print "</td>"; print '<td align="left"><a href="fiche.php?socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,44).'</a></td>'."\n"; print '<td align="right">'; print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; print '</tr>'."\n"; $i++; $total += $obj->total_ttc; } if ($total>0) { print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; } print "</table><br>"; } } else
/** * Show list of documents in a directory * * @param string $upload_dir Directory that was scanned * @param array $filearray Array of files loaded by dol_dir_list function before calling this function * @param string $modulepart Value for modulepart used by download wrapper * @param string $param Parameters on sort links * @param int $forcedownload Force to open dialog box "Save As" when clicking on file * @param string $relativepath Relative path of docs (autodefined if not provided) * @param int $permtodelete Permission to delete * @param int $useinecm Change output for use in ecm module * @param int $textifempty Text to show if filearray is empty * @param int $maxlength Maximum length of file name shown * @param string $url Full url to use for click links ('' = autodetect) * @return int <0 if KO, nb of files shown if OK */ function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '') { global $user, $conf, $langs; global $bc; global $sortfield, $sortorder; dol_syslog(get_class($this) . '::list_of_autoecmfiles upload_dir=' . $upload_dir . ' modulepart=' . $modulepart); // Show list of documents if (empty($useinecm)) { print load_fiche_titre($langs->trans("AttachedFiles")); } if (empty($url)) { $url = $_SERVER["PHP_SELF"]; } print '<table width="100%" class="nobordernopadding">'; print '<tr class="liste_titre">'; $sortref = "fullname"; if ($modulepart == 'invoice_supplier') { $sortref = 'level1name'; } print_liste_field_titre($langs->trans("Ref"), $url, $sortref, "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Documents2"), $url, "name", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Size"), $url, "size", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Date"), $url, "date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('', '', ''); print '</tr>'; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $object_instance = new Societe($this->db); } else { if ($modulepart == 'invoice') { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $object_instance = new Facture($this->db); } else { if ($modulepart == 'invoice_supplier') { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $object_instance = new FactureFournisseur($this->db); } else { if ($modulepart == 'propal') { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $object_instance = new Propal($this->db); } else { if ($modulepart == 'supplier_proposal') { include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; $object_instance = new SupplierProposal($this->db); } else { if ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $object_instance = new Commande($this->db); } else { if ($modulepart == 'order_supplier') { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $object_instance = new CommandeFournisseur($this->db); } else { if ($modulepart == 'contract') { include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $object_instance = new Contrat($this->db); } else { if ($modulepart == 'product') { include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $object_instance = new Product($this->db); } else { if ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($this->db); } else { if ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $object_instance = new Project($this->db); } else { if ($modulepart == 'fichinter') { include_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php'; $object_instance = new Fichinter($this->db); } else { if ($modulepart == 'user') { include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; $object_instance = new User($this->db); } } } } } } } } } } } } } $var = true; foreach ($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && !preg_match('/\\.meta$/i', $file['name'])) { // Define relative path used to store the file $relativefile = preg_replace('/' . preg_quote($upload_dir . '/', '/') . '/', '', $file['fullname']); //var_dump($file); $id = 0; $ref = ''; $label = ''; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'invoice') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'invoice_supplier') { preg_match('/([^\\/]+)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; if (is_numeric($ref)) { $id = $ref; $ref = ''; } } // $ref may be also id with old supplier invoices if ($modulepart == 'propal') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'supplier_proposal') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'order') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'order_supplier') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'contract') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'product') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'tax') { preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'project') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'fichinter') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'user') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if (!$id && !$ref) { continue; } $found = 0; if (!empty($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { $found = 1; } else { //print 'Fetch '.$id." - ".$ref.'<br>'; if ($id) { $result = $object_instance->fetch($id); } else { //fetchOneLike looks for objects with wildcards in its reference. //It is useful for those masks who get underscores instead of their actual symbols //fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned //that's why we look only look fetchOneLike when fetch returns 0 if (!($result = $object_instance->fetch('', $ref))) { $result = $object_instance->fetchOneLike($ref); } } if ($result > 0) { // Save object into a cache $found = 1; $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = clone $object_instance; } if ($result == 0) { $found = 1; $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = 'notfound'; unset($filearray[$key]); } } if (!$found > 0 || !is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { continue; } // We do not show orphelins files $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>'; if ($found > 0 && is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { print $this->cache_objects[$modulepart . '_' . $id . '_' . $ref]->getNomUrl(1, 'document'); } else { print $langs->trans("ObjectDeleted", $id ? $id : $ref); } print '</td>'; print '<td>'; //print "XX".$file['name']; //$file['name'] must be utf8 print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart; if ($forcedownload) { print '&attachment=1'; } print '&file=' . urlencode($relativefile) . '">'; print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' '; print dol_trunc($file['name'], $maxlength, 'middle'); print '</a>'; print "</td>\n"; print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>'; print '<td align="center">' . dol_print_date($file['date'], "dayhour") . '</td>'; print '<td align="right">'; if (!empty($useinecm)) { print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart; } if ($forcedownload) { print '&attachment=1'; } print '&file=' . urlencode($relativefile) . '">'; print img_view() . '</a> '; //if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>'; //else print ' '; print "</td></tr>\n"; } } if (count($filearray) == 0) { print '<tr ' . $bc[false] . '><td colspan="4">'; if (empty($textifempty)) { print $langs->trans("NoFileFound"); } else { print $textifempty; } print '</td></tr>'; } print "</table>"; // Fin de zone }
$bankstatic->id = $objp->bankid; $bankstatic->label = $objp->bankref; $comment .= ' (' . $langs->transnoentitiesnoconv("from") . ' '; $comment .= $bankstatic->getNomUrl(1, ''); $comment .= ' ' . $langs->transnoentitiesnoconv("toward") . ' '; $banklinestatic->fetch($links[$key]['url_id']); $bankstatic->id = $banklinestatic->fk_account; $bankstatic->label = $banklinestatic->bank_account_label; $comment .= $bankstatic->getNomUrl(1, 'transactions'); $comment .= ')'; } } elseif ($links[$key]['type'] == 'company') { if ($thirdparty) { $thirdparty .= ', '; } $thirdparty .= dol_trunc($links[$key]['label'], 24); $newline = 0; } elseif ($links[$key]['type'] == 'member') { if ($thirdparty) { $accountelem .= ', '; } $thirdparty .= $links[$key]['label']; $newline = 0; } /*elseif ($links[$key]['type']=='sc') { if ($accountelem) $accountelem.= ', '; //$accountelem.= '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">'; //$accountelem.= img_object($langs->transnoentitiesnoconv('ShowBill'),'bill').' '; $accountelem.= $langs->transnoentitiesnoconv("SocialContribution"); //$accountelem.= '</a>';
$var = !$var; print "<tr " . $bc[$var] . ">"; print "<td>"; $interventionstatic->id = $objp->fichid; $interventionstatic->ref = $objp->ref; print $interventionstatic->getNomUrl(1); print "</td>\n"; print '<td>'; $companystatic->name = $objp->name; $companystatic->id = $objp->socid; $companystatic->client = $objp->client; print $companystatic->getNomUrl(1, '', 44); print '</td>'; print '<td>' . dol_htmlentitiesbr(dol_trunc($objp->description, 20)) . '</td>'; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print '<td>' . dol_htmlentitiesbr(dol_trunc($objp->descriptiondetail, 20)) . '</td>'; print '<td align="center">' . dol_print_date($db->jdate($objp->dp), 'dayhour') . "</td>\n"; print '<td align="right">' . convertSecondToTime($objp->duree) . '</td>'; } print '<td align="right">' . $interventionstatic->LibStatut($objp->fk_statut, 5) . '</td>'; print '<td> </td>'; print "</tr>\n"; $total += $objp->duree; $i++; } $rowspan = 3; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { print '<tr class="liste_total"><td colspan="5" class="liste_total">' . $langs->trans("Total") . '</td>'; print '<td align="right" class="nowrap liste_total">' . convertSecondToTime($total) . '</td><td> </td><td> </td>'; print '</tr>'; }
/** *Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox function) * * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * * @return void */ function showBox($head, $contents) { global $langs, $user, $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $MAXLENGTHBOX = 60; // Mettre 0 pour pas de limite $bcx = array(); $bcx[0] = 'class="box_pair"'; $bcx[1] = 'class="box_impair"'; $var = false; $cachetime = 900; // 900 : 15mn $cachedir = DOL_DATA_ROOT . '/boxes/temp'; $fileid = get_class($this) . 'id-' . $this->box_id . '-e' . $conf->entity . '-u' . $user->id . '-s' . $user->societe_id . '.cache'; $filename = '/box-' . $fileid; $refresh = dol_cache_refresh($cachedir, $filename, $cachetime); $out = ''; if ($refresh) { dol_syslog(get_class($this) . '::showBox'); // Define nbcol and nblines of the box to show $nbcol = 0; if (isset($contents[0])) { $nbcol = count($contents[0]); } $nblines = count($contents); $out .= "\n<!-- Box " . get_class($this) . " start -->\n"; $out .= '<div class="box" id="boxto_' . $this->box_id . '">' . "\n"; if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) { $out .= '<table summary="boxtable' . $this->box_id . '" width="100%" class="noborder boxtable">' . "\n"; } // Show box title if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) { //$out.= '<div id="boxto_'.$this->box_id.'_title">'."\n"; //$out.= '<table summary="boxtabletitle'.$this->box_id.'" width="100%" class="noborder">'."\n"; $out .= '<tr class="box_titre">'; $out .= '<td'; if ($nbcol > 0) { $out .= ' colspan="' . $nbcol . '"'; } $out .= '>'; if ($conf->use_javascript_ajax) { $out .= '<table summary="" class="nobordernopadding" width="100%"><tr><td>'; } if (!empty($head['text'])) { $s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX); $out .= $s; } $out .= ' '; if (!empty($head['sublink'])) { $out .= '<a href="' . $head['sublink'] . '"' . (empty($head['target']) ? ' target="_blank"' : '') . '>'; } if (!empty($head['subpicto'])) { $out .= img_picto($head['subtext'], $head['subpicto'], 'class="' . (empty($head['subclass']) ? '' : $head['subclass']) . '" id="idsubimg' . $this->boxcode . '"'); } if (!empty($head['sublink'])) { '</a>'; } if (!empty($conf->use_javascript_ajax)) { $out .= '</td><td class="nocellnopadd boxclose nowrap">'; // The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object $out .= img_picto($langs->trans("MoveBox", $this->box_id), 'grip_title', 'class="boxhandle hideonsmartphone" style="cursor:move;"'); $out .= img_picto($langs->trans("Close2", $this->box_id), 'close_title', 'class="boxclose" rel="x:y" style="cursor:pointer;" id="imgclose' . $this->box_id . '"'); $label = $head['text']; if (!empty($head['graph'])) { $label .= ' (' . $langs->trans("Graph") . ')'; } $out .= '<input type="hidden" id="boxlabelentry' . $this->box_id . '" value="' . dol_escape_htmltag($label) . '">'; $out .= '</td></tr></table>'; } $out .= '</td>'; $out .= "</tr>\n"; //$out.= "</table>\n"; //$out.= "</div>\n"; } // Show box lines if ($nblines) { //$out.= '<table summary="boxtablelines'.$this->box_id.'" width="100%" class="noborder">'."\n"; // Loop on each record for ($i = 0, $n = $nblines; $i < $n; $i++) { if (isset($contents[$i])) { $var = !$var; // TR if (isset($contents[$i][0]['tr'])) { $out .= '<tr valign="top" ' . $contents[$i][0]['tr'] . '>'; } else { $out .= '<tr valign="top" ' . $bcx[$var] . '>'; } // Loop on each TD $nbcolthisline = count($contents[$i]); for ($j = 0; $j < $nbcolthisline; $j++) { // Define tdparam $tdparam = ''; if (isset($contents[$i][$j]['td'])) { $tdparam .= ' ' . $contents[$i][$j]['td']; } $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); $text2 = isset($contents[$i][$j]['text2']) ? $contents[$i][$j]['text2'] : ''; $text2withnotags = preg_replace('/<([^>]+)>/i', '', $text2); $textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : ''; //$out.= "xxx $textwithnotags y"; if (empty($contents[$i][$j]['tooltip'])) { $contents[$i][$j]['tooltip'] = ""; } $tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : ''; $out .= '<td' . $tdparam . '>' . "\n"; // Url if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) { $out .= '<a href="' . $contents[$i][$j]['url'] . '" title="' . dol_escape_htmltag($langs->trans("Show") . ' ' . $tooltip, 1) . '" class="classfortooltip"'; //$out.= ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "<a href>" $out .= isset($contents[$i][$j]['target']) ? ' target="' . $contents[$i][$j]['target'] . '"' : ''; $out .= '>'; } // Logo if (!empty($contents[$i][$j]['logo'])) { $logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']); $out .= '<a href="' . $contents[$i][$j]['url'] . '">'; $out .= img_object($langs->trans("Show") . ' ' . $tooltip, $logo, 'class="classfortooltip"'); } $maxlength = $MAXLENGTHBOX; if (!empty($contents[$i][$j]['maxlength'])) { $maxlength = $contents[$i][$j]['maxlength']; } if ($maxlength) { $textwithnotags = dol_trunc($textwithnotags, $maxlength); } if (preg_match('/^<img/i', $text) || !empty($contents[$i][$j]['asis'])) { $out .= $text; } else { $out .= $textwithnotags; } // show text with html cleaning // End Url if (!empty($contents[$i][$j]['url'])) { $out .= '</a>'; } if (preg_match('/^<img/i', $text2) || !empty($contents[$i][$j]['asis2'])) { $out .= $text2; } else { $out .= $text2withnotags; } // show text with html cleaning if (!empty($textnoformat)) { $out .= "\n" . $textnoformat . "\n"; } $out .= "</td>\n"; } $out .= "</tr>\n"; } } } if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) { $out .= "</table>\n"; } // If invisible box with no contents if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) { $out .= "<br>\n"; } $out .= "</div>\n"; $out .= "<!-- Box " . get_class($this) . " end -->\n\n"; if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { dol_filecache($cachedir, $filename, $out); } } else { dol_syslog(get_class($this) . '::showBoxCached'); $out = dol_readcachefile($cachedir, $filename); print "<!-- Box " . get_class($this) . " from cache -->"; } print $out; }
/** * \brief Renvoie nom clicable (avec eventuellement le picto) * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * \param maxlength Max length of ref * \return string Chaine avec URL */ function getNomUrl($withpicto=0,$maxlength=0) { global $langs; $result=''; $lien = '<a href="'.DOL_URL_ROOT.'/contrat/fiche.php?id='.$this->id.'">'; $lienfin='</a>'; $picto='contract'; $label=$langs->trans("ShowContract").': '.$this->ref; if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.($maxlength?dol_trunc($this->ref,$maxlength):$this->ref).$lienfin; return $result; }
print '<td width="20" class="nobordernopadding" nowrap="nowrap">'; if ($date_limit < $now - $conf->facture->client->warning_delay && !$objp->paye && $objp->fk_statut == 1) { print img_warning($langs->trans("Late")); } print '</td>'; // PDF Picto print '<td width="16" align="right" class="nobordernopadding">'; $filename = dol_sanitizeFileName($objp->facnumber); $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($objp->facnumber); $foundpdf = $formfile->show_documents('facture', $filename, $filedir, $urlsource, '', '', '', 1, '', 1, $param); print '</td>'; print '</tr></table>'; print "</td>\n"; print '<td nowrap align="center">' . dol_print_date($db->jdate($objp->df), 'day') . '</td>' . "\n"; print '<td nowrap align="center">' . dol_print_date($db->jdate($objp->datelimite), 'day') . '</td>' . "\n"; print '<td><a href="' . DOL_URL_ROOT . '/comm/fiche.php?socid=' . $objp->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . dol_trunc($objp->nom, 28) . '</a></td>'; print '<td align="right">' . price($objp->total_ht) . '</td>'; print '<td align="right">' . price($objp->total_ttc) . '</td>'; print '<td align="right">' . price($objp->am) . '</td>'; if ($objp->am == 0) { print '<td align="right"></td>'; } else { print '<td align="right">' . price($objp->total_ttc - $objp->am) . '</td>'; } // Affiche statut de la facture print '<td align="right" nowrap="nowrap">'; print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $objp->am); print '</td>'; // Checkbox print '<td align="center">'; if ($foundpdf) {
// ID print '<td align="left" class="nowrap">'; if ("{$key}" == session_id()) { print $form->textwithpicto($key, $langs->trans("YourSession")); } else { print $key; } print '</td>'; // Date creation print '<td align="left" class="nowrap">' . dol_print_date($sessionentry['creation'], '%Y-%m-%d %H:%M:%S') . '</td>'; // Date modification print '<td align="left" class="nowrap">' . dol_print_date($sessionentry['modification'], '%Y-%m-%d %H:%M:%S') . '</td>'; // Age print '<td>' . $sessionentry['age'] . '</td>'; // Raw print '<td>' . dol_trunc($sessionentry['raw'], 40, 'middle') . '</td>'; print '<td> </td>'; print "</tr>\n"; $i++; } if (count($listofsessions) == 0) { print '<tr><td colspan="6">' . $langs->trans("NoSessionFound", $savepath, $openbasedir) . '</td></tr>'; } print "</table>"; } else { print $langs->trans("NoSessionListWithThisHandler"); } /* * Buttons */ print '<div class="tabsAction">';
/** * Renvoie tags list clicable (avec eventuellement le picto) * * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $maxlen length max libelle * @return string String with URL */ function getTagUrl($withpicto = 0, $maxlen = 0) { global $langs; $result = ''; if (count($this->Tag)) { for ($i = 0; $i < count($this->Tag); $i++) { $lien = '<a href="' . DOL_URL_ROOT . '/adherent/type.php?id=' . $this->Tag[$i] . '">'; $lienfin = '</a> '; $picto = 'group'; $label = $langs->trans("ShowTypeCard", $this->Tag[$i]); if ($withpicto) { $result .= $lien . img_object($label, $picto) . $lienfin; } if ($withpicto && $withpicto != 2) { $result .= ' '; } $result .= $lien . ($maxlen ? dol_trunc($this->Tag[$i], $maxlen) : $this->Tag[$i]) . $lienfin; } } return $result; }
/** * Load data for box to show them later * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $contractstatic = new Contrat($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max)); if ($user->rights->contrat->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "contrat as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity = " . $conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC "; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $now = dol_now(); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $datec = $db->jdate($objp->datec); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $late = ''; $contractstatic->statut = $objp->fk_statut; $contractstatic->id = $objp->rowid; $result = $contractstatic->fetch_lines(); // fin_validite is no more on contract but on services // if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->contrat->cloture->warning_delay)) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/contrat/fiche.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref ? $objp->ref : $objp->rowid, 'text2' => $late, 'url' => DOL_URL_ROOT . "/contrat/fiche.php?id=" . $objp->rowid); $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->nom, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid); $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datec, 'day')); $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', 'text' => $contractstatic->getLibStatut(6), 'asis' => 1); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedContracts")); } $db->free($resql); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
print '<td align="left">'; if ($fields['pid']) { $product_static->id = $fields['pid']; $product_static->ref = $fields['pref']; $product_static->type = $fields['ptype']; print $product_static->getNomUrl(1); if (dol_string_nohtmltag($fields['descr'])) { print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 16); } } else { if ($type) { $text = img_object($langs->trans('Service'), 'service'); } else { $text = img_object($langs->trans('Product'), 'product'); } print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 16); // Show range print_date_range($fields['ddate_start'], $fields['ddate_end']); } print '</td>'; // Total HT if ($modetax == 0) { print '<td class="nowrap" align="right">'; print price($fields['totalht']); if (price2num($fields['ftotal_ttc'])) { //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; $ratiolineinvoice = $fields['dtotal_ttc'] / $fields['ftotal_ttc']; //print ' ('.round($ratiolineinvoice*100,2).'%)'; } print '</td>'; }
print "</tr>\n"; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $var = !$var; print "<tr " . $bc[$var] . ">"; // Ref print '<td width="60">'; $chargesociale_static->id = $obj->id; $chargesociale_static->lib = $obj->id; $chargesociale_static->ref = $obj->id; print $chargesociale_static->getNomUrl(1, '20'); print '</td>'; // Label print '<td>' . dol_trunc($obj->libelle, 42) . '</td>'; // Type print '<td>' . dol_trunc($obj->type_lib, 16) . '</td>'; // Date end period print '<td align="center">'; if ($obj->periode) { print '<a href="index.php?year=' . strftime("%Y", $db->jdate($obj->periode)) . '">' . dol_print_date($db->jdate($obj->periode), 'day') . '</a>'; } else { print ' '; } print '</td>'; print '<td align="right" width="100">' . price($obj->amount) . '</td>'; // Due date print '<td width="110" align="center">' . dol_print_date($db->jdate($obj->date_ech), 'day') . '</td>'; print '<td align="right" class="nowrap">' . $chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '</a></td>'; print '</tr>'; $i++; }
$facture_static->ref = $objp->facnumber; $facture_static->id = $objp->facid; print '<td>' . $facture_static->getNomUrl(1) . '</td>'; // Ref produit $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; print '<td>'; if ($product_static->id) { print $product_static->getNomUrl(1); } else { print ' '; } print '</td>'; print '<td>' . dol_trunc($objp->product_label, 24) . '</td>'; print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>'; print '<td align="right">'; print price($objp->price); print '</td>'; print '<td align="right"><a href="fiche.php?id=' . $objp->rowid . '">'; print img_edit(); print '</a></td>'; print "</tr>"; $i++; } print "</table>"; } else { print $db->error(); } llxFooter(); $db->close();
/** * Return HTML string to put an output field into a page * * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parametes on html input tag (only checkbox use html input for output rendering) * @return string Formated value */ function showOutputField($key, $value, $moreparam = '') { global $conf, $langs; $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; $size = $this->attribute_size[$key]; $elementtype = $this->attribute_elementtype[$key]; $unique = $this->attribute_unique[$key]; $required = $this->attribute_required[$key]; $params = $this->attribute_param[$key]; $perms = $this->attribute_perms[$key]; $list = $this->attribute_list[$key]; $showsize = 0; if ($type == 'date') { $showsize = 10; $value = dol_print_date($value, 'day'); } elseif ($type == 'datetime') { $showsize = 19; $value = dol_print_date($value, 'dayhour'); } elseif ($type == 'int') { $showsize = 10; } elseif ($type == 'double') { if (!empty($value)) { $value = price($value); } } elseif ($type == 'boolean') { $checked = ''; if (!empty($value)) { $checked = ' checked '; } $value = '<input type="checkbox" ' . $checked . ' ' . ($moreparam ? $moreparam : '') . ' readonly disabled>'; } elseif ($type == 'mail') { $value = dol_print_email($value); } elseif ($type == 'phone') { $value = dol_print_phone($value); } elseif ($type == 'price') { $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); } elseif ($type == 'select') { $value = $params['options'][$value]; } elseif ($type == 'sellist') { $param_list = array_keys($params['options']); $InfoFieldList = explode(":", $param_list[0]); $selectkey = "rowid"; $keyList = 'rowid'; if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; $keyList = $InfoFieldList[2] . ' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $keyList .= ', '; $keyList .= implode(', ', $fields_label); } $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; } $sql .= " WHERE " . $selectkey . "='" . $this->db->escape($value) . "'"; //$sql.= ' AND entity = '.$conf->entity; dol_syslog(get_class($this) . ':showOutputField:$type=sellist', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $value = ''; // value was used, so now we reste it to use it to build final output $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->{$field_toshow})) { $translabel = $langs->trans($obj->{$field_toshow}); } if ($translabel != $field_toshow) { $value .= dol_trunc($translabel, 18) . ' '; } else { $value .= $obj->{$field_toshow} . ' '; } } } else { $translabel = ''; if (!empty($obj->{$InfoFieldList}[1])) { $translabel = $langs->trans($obj->{$InfoFieldList}[1]); } if ($translabel != $obj->{$InfoFieldList}[1]) { $value = dol_trunc($translabel, 18); } else { $value = $obj->{$InfoFieldList}[1]; } } } else { dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); } } elseif ($type == 'radio') { $value = $params['options'][$value]; } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); $value = ''; if (is_array($value_arr)) { foreach ($value_arr as $keyval => $valueval) { $value .= $params['options'][$valueval] . '<br>'; } } } elseif ($type == 'chkbxlst') { $value_arr = explode(',', $value); $param_list = array_keys($params['options']); $InfoFieldList = explode(":", $param_list[0]); $selectkey = "rowid"; $keyList = 'rowid'; if (count($InfoFieldList) >= 3) { $selectkey = $InfoFieldList[2]; $keyList = $InfoFieldList[2] . ' as rowid'; } $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $keyList .= ', '; $keyList .= implode(', ', $fields_label); } $sql = 'SELECT ' . $keyList; $sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0]; if (strpos($InfoFieldList[4], 'extra') !== false) { $sql .= ' as main'; } // $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'"; // $sql.= ' AND entity = '.$conf->entity; dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $value = ''; // value was used, so now we reste it to use it to build final output while ($obj = $this->db->fetch_object($resql)) { // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($fields_label) && count($fields_label) > 1) { foreach ($fields_label as $field_toshow) { $translabel = ''; if (!empty($obj->{$field_toshow})) { $translabel = $langs->trans($obj->{$field_toshow}); } if ($translabel != $field_toshow) { $value .= dol_trunc($translabel, 18) . '<BR>'; } else { $value .= $obj->{$field_toshow} . '<BR>'; } } } else { $translabel = ''; if (!empty($obj->{$InfoFieldList}[1])) { $translabel = $langs->trans($obj->{$InfoFieldList}[1]); } if ($translabel != $obj->{$InfoFieldList}[1]) { $value .= dol_trunc($translabel, 18) . '<BR>'; } else { $value .= $obj->{$InfoFieldList}[1] . '<BR>'; } } } } } else { dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); } } elseif ($type == 'link') { $out = ''; // only if something to display (perf) if ($value) { $param_list = array_keys($params['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) { $object = new $InfoFieldList[0]($this->db); $object->fetch($value); $value = $object->getNomUrl(3); } else { dol_syslog('Error bad setup of extrafield', LOG_WARNING); $out .= 'Error bad setup of extrafield'; } } } elseif ($type == 'text') { $value = dol_htmlentitiesbr($value); } else { $showsize = round($size); if ($showsize > 48) { $showsize = 48; } } //print $type.'-'.$size; $out = $value; return $out; }
/** * Return clicable link of object (with eventually picto) * * @param int $withpicto Add picto into link * @param string $option Where point the link * @param int $max Maxlength of ref * @param int $short 1=Return just URL * @param string $moretitle Add more text to title tooltip * @return string String with URL */ function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '') { global $langs, $conf; $result = ''; if ($option == 'withdraw') { $url = DOL_URL_ROOT . '/compta/facture/prelevement.php?facid=' . $this->id; } else { $url = DOL_URL_ROOT . '/compta/facture.php?facid=' . $this->id; } if ($short) { return $url; } $picto = 'bill'; if ($this->type == self::TYPE_REPLACEMENT) { $picto .= 'r'; } // Replacement invoice if ($this->type == self::TYPE_CREDIT_NOTE) { $picto .= 'a'; } // Credit note if ($this->type == self::TYPE_DEPOSIT) { $picto .= 'd'; } // Deposit invoice $label = '<u>' . $langs->trans("ShowInvoice") . '</u>'; if (!empty($this->ref)) { $label .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; } if (!empty($this->ref_client)) { $label .= '<br><b>' . $langs->trans('RefCustomer') . ':</b> ' . $this->ref_client; } if (!empty($this->total_ht)) { $label .= '<br><b>' . $langs->trans('AmountHT') . ':</b> ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_tva)) { $label .= '<br><b>' . $langs->trans('VAT') . ':</b> ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_ttc)) { $label .= '<br><b>' . $langs->trans('AmountTTC') . ':</b> ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); } if ($this->type == self::TYPE_REPLACEMENT) { $label = $langs->transnoentitiesnoconv("ShowInvoiceReplace") . ': ' . $this->ref; } if ($this->type == self::TYPE_CREDIT_NOTE) { $label = $langs->transnoentitiesnoconv("ShowInvoiceAvoir") . ': ' . $this->ref; } if ($this->type == self::TYPE_DEPOSIT) { $label = $langs->transnoentitiesnoconv("ShowInvoiceDeposit") . ': ' . $this->ref; } if ($this->type == self::TYPE_SITUATION) { $label = $langs->transnoentitiesnoconv("ShowInvoiceSituation") . ': ' . $this->ref; } if ($moretitle) { $label .= ' - ' . $moretitle; } $linkstart = '<a href="' . $url . '" title="' . dol_escape_htmltag($label, 1) . '" class="classfortooltip">'; $linkend = '</a>'; if ($withpicto) { $result .= $linkstart . img_object($max ? dol_trunc($label, $max) : $label, $picto, 'class="classfortooltip"') . $linkend; } if ($withpicto && $withpicto != 2) { $result .= ' '; } if ($withpicto != 2) { $result .= $linkstart . ($max ? dol_trunc($this->ref, $max) : $this->ref) . $linkend; } return $result; }
/** * Return list of contacts mobile phone existing for third party * @return array Array of contacts emails */ function thirdparty_and_contact_phone_array() { global $langs; $contact_phone = $this->contact_property_array('mobile'); if ($this->tel) { if (empty($this->name)) $this->name=$this->nom; // TODO: Tester si tel non deja present dans tableau contact $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->tel.">"; } return $contact_phone; }
if (is_array($result)) { $var = true; $i = 0; //$num = sizeOf($result); $num = $chronodocs_static->get_nb_chronodocs($objsoc->id); if ($num > 0) { print '<tr class="liste_titre">'; print '<td colspan="3"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastChronodocs", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/chronodocs/index.php?socid=' . $objsoc->id . '">' . $langs->trans("AllChronodocs") . ' (' . $num . ')</td></tr></table></td>'; print '</tr>'; } while ($i < $num && $i < $MAXLIST) { $obj = array_shift($result); $var = !$var; print "<tr {$bc[$var]}>"; print '<td><a href="' . DOL_URL_ROOT . '/chronodocs/fiche.php?id=' . $obj->fichid . '">' . img_object($langs->trans("ShowChronodocs"), "generic") . " " . $obj->ref . '</a></td>'; print "<td align=\"left\">" . dol_trunc($obj->title, 30) . "</td>"; print "<td align=\"right\">" . dol_print_date($db->jdate($obj->dp), 'day') . "</td>\n"; print "</tr>"; $i++; } } print "</table>"; } print "</td></tr>"; print "</table>"; print "\n</div>\n"; /* * Barre d'actions */ print '<div class="tabsAction">'; if ($conf->propal->enabled && $user->rights->propale->creer) {