function _fiche(&$PDOdb, &$assetOf, $mode = 'edit', $fk_product_to_add = 0, $fk_nomenclature = 0) { global $langs, $db, $conf, $user, $hookmanager; /*************************************************** * PAGE * * Put here all code to build page ****************************************************/ $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('doActions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook //pre($assetOf,true); llxHeader('', $langs->trans('OFAsset'), '', ''); print dol_get_fiche_head(ofPrepareHead($assetOf, 'assetOF'), 'fiche', $langs->trans('OFAsset')); ?> <style type="text/css"> #assetChildContener .OFMaster { background:#fff; -webkit-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); -moz-box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); box-shadow: 4px 4px 5px 0px rgba(50, 50, 50, 0.52); margin-bottom:20px; } </style> <div class="OFContent" rel="<?php echo $assetOf->getId(); ?> "> <?php $TPrixFournisseurs = array(); //$form=new TFormCore($_SERVER['PHP_SELF'],'formeq'.$assetOf->getId(),'POST'); //Affichage des erreurs if (!empty($assetOf->errors)) { ?> <br><div class="error"> <?php foreach ($assetOf->errors as $error) { echo $error . "<br>"; setEventMessage($error, 'errors'); } $assetOf->errors = array(); ?> </div><br> <?php } $form = new TFormCore(); $form->Set_typeaff($mode); $doliform = new Form($db); if (!empty($_REQUEST['fk_product'])) { echo $form->hidden('fk_product', $_REQUEST['fk_product']); } $TBS = new TTemplateTBS(); $liste = new TListviewTBS('asset'); $TBS->TBS->protect = false; $TBS->TBS->noerr = true; $PDOdb = new TPDOdb(); $TNeeded = array(); $TToMake = array(); $TNeeded = _fiche_ligne($form, $assetOf, "NEEDED"); $TToMake = _fiche_ligne($form, $assetOf, "TO_MAKE"); $TIdCommandeFourn = $assetOf->getElementElement($PDOdb); $HtmlCmdFourn = ''; if (count($TIdCommandeFourn)) { foreach ($TIdCommandeFourn as $idcommandeFourn) { $cmd = new CommandeFournisseur($db); $cmd->fetch($idcommandeFourn); $HtmlCmdFourn .= $cmd->getNomUrl(1) . " - " . $cmd->getLibStatut(0); } } ob_start(); $doliform->select_produits('', 'fk_product', '', $conf->product->limit_size, 0, -1, 2, '', 3, array()); $select_product = ob_get_clean(); $Tid = array(); //$Tid[] = $assetOf->rowid; if ($assetOf->getId() > 0) { $assetOf->getListeOFEnfants($PDOdb, $Tid); } $TWorkstation = array(); foreach ($assetOf->TAssetWorkstationOF as $k => &$TAssetWorkstationOF) { $ws =& $TAssetWorkstationOF->ws; $TWorkstation[] = array('libelle' => '<a href="' . dol_buildpath('workstation/workstation.php?id=' . $ws->rowid . '&action=view', 2) . '">' . $ws->name . '</a>', 'fk_user' => visu_checkbox_user($PDOdb, $form, $ws->fk_usergroup, $TAssetWorkstationOF->users, 'TAssetWorkstationOF[' . $k . '][fk_user][]', $assetOf->status), 'fk_project_task' => visu_project_task($db, $TAssetWorkstationOF->fk_project_task, $form->type_aff, 'TAssetWorkstationOF[' . $k . '][progress]'), 'fk_task' => visu_checkbox_task($PDOdb, $form, $TAssetWorkstationOF->fk_asset_workstation, $TAssetWorkstationOF->tasks, 'TAssetWorkstationOF[' . $k . '][fk_task][]', $assetOf->status), 'nb_hour' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour]', $TAssetWorkstationOF->nb_hour, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour * 3600) : price($TAssetWorkstationOF->nb_hour)), 'nb_hour_real' => $assetOf->status == 'OPEN' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_hour_real]', $TAssetWorkstationOF->nb_hour_real, 3, 10) : ($conf->global->ASSET_USE_CONVERT_TO_TIME ? convertSecondToTime($TAssetWorkstationOF->nb_hour_real * 3600) : price($TAssetWorkstationOF->nb_hour_real)), 'nb_days_before_beginning' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][nb_days_before_beginning]', $TAssetWorkstationOF->nb_days_before_beginning, 3, 10) : $TAssetWorkstationOF->nb_days_before_beginning, 'delete' => $mode == 'edit' && $assetOf->status == 'DRAFT' ? '<a href="javascript:deleteWS(' . $assetOf->getId() . ',' . $TAssetWorkstationOF->getId() . ');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'note_private' => $assetOf->status == 'DRAFT' && $mode == 'edit' ? $form->zonetexte('', 'TAssetWorkstationOF[' . $k . '][note_private]', $TAssetWorkstationOF->note_private, 50, 1) : $TAssetWorkstationOF->note_private, 'rang' => $assetOf->status == 'DRAFT' && $mode == "edit" ? $form->texte('', 'TAssetWorkstationOF[' . $k . '][rang]', $TAssetWorkstationOF->rang, 3, 10) : $TAssetWorkstationOF->rang, 'id' => $ws->getId()); } $client = new Societe($db); if ($assetOf->fk_soc > 0) { $client->fetch($assetOf->fk_soc); } $commande = new Commande($db); if ($assetOf->fk_commande > 0) { $commande->fetch($assetOf->fk_commande); } $TOFParent = array_merge(array(0 => ''), $assetOf->getCanBeParent($PDOdb)); $hasParent = false; if (!empty($assetOf->fk_assetOf_parent)) { $TAssetOFParent = new TAssetOF(); $TAssetOFParent->load($PDOdb, $assetOf->fk_assetOf_parent); $hasParent = true; } $parameters = array('id' => $assetOf->getId()); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $assetOf, $mode); // Note that $action and $object may have been modified by hook if ($fk_product_to_add > 0) { $product_to_add = new Product($db); $product_to_add->fetch($fk_product_to_add); $link_product_to_add = $product_to_add->getNomUrl(1) . ' ' . $product_to_add->label; $quantity_to_create = $form->texte('', 'quantity_to_create', 1, 3, 255); } else { $link_product_to_add = ''; $quantity_to_create = ''; } print $TBS->render('tpl/fiche_of.tpl.php', array('TNeeded' => $TNeeded, 'TTomake' => $TToMake, 'workstation' => $TWorkstation), array('assetOf' => array('id' => $assetOf->getId(), 'numero' => $assetOf->getId() > 0 ? '<a href="fiche_of.php?id=' . $assetOf->getId() . '">' . $assetOf->getNumero($PDOdb) . '</a>' : $assetOf->getNumero($PDOdb), 'ordre' => $form->combo('', 'ordre', TAssetOf::$TOrdre, $assetOf->ordre), 'fk_commande' => $assetOf->fk_commande == 0 ? '' : $commande->getNomUrl(1), 'commande_fournisseur' => $HtmlCmdFourn, 'date_besoin' => $form->calendrier('', 'date_besoin', $assetOf->date_besoin, 12, 12), 'date_lancement' => $form->calendrier('', 'date_lancement', $assetOf->date_lancement, 12, 12), 'temps_estime_fabrication' => price($assetOf->temps_estime_fabrication, 0, '', 1, -1, 2), 'temps_reel_fabrication' => price($assetOf->temps_reel_fabrication, 0, '', 1, -1, 2), 'fk_soc' => $mode == 'edit' ? $doliform->select_company($assetOf->fk_soc, 'fk_soc', 'client=1', 1) : ($client->id ? $client->getNomUrl(1) : ''), 'fk_project' => custom_select_projects(-1, $assetOf->fk_project, 'fk_project', $mode), 'note' => $form->zonetexte('', 'note', $assetOf->note, 80, 5), 'quantity_to_create' => $quantity_to_create, 'product_to_create' => $link_product_to_add, 'status' => $form->combo('', 'status', TAssetOf::$TStatus, $assetOf->status), 'statustxt' => TAssetOf::$TStatus[$assetOf->status], 'idChild' => !empty($Tid) ? '"' . implode('","', $Tid) . '"' : '', 'url' => dol_buildpath('/of/fiche_of.php', 2), 'url_liste' => $assetOf->getId() ? dol_buildpath('/of/fiche_of.php?id=' . $assetOf->getId(), 2) : dol_buildpath('/of/liste_of.php', 2), 'fk_product_to_add' => $fk_product_to_add, 'fk_nomenclature' => $fk_nomenclature, 'fk_assetOf_parent' => $assetOf->fk_assetOf_parent ? $assetOf->fk_assetOf_parent : '', 'link_assetOf_parent' => $hasParent ? '<a href="' . dol_buildpath('/of/fiche_of.php?id=' . $TAssetOFParent->rowid, 2) . '">' . $TAssetOFParent->numero . '</a>' : '', 'total_cost' => price($assetOf->total_cost, 0, '', 1, -1, 2), 'total_estimated_cost' => price($assetOf->total_estimated_cost, 0, '', 1, -1, 2), 'mo_cost' => price($assetOf->mo_cost, 0, '', 1, -1, 2), 'mo_estimated_cost' => price($assetOf->mo_estimated_cost, 0, '', 1, -1, 2), 'compo_cost' => price($assetOf->compo_cost, 0, '', 1, -1, 2), 'compo_estimated_cost' => price($assetOf->compo_estimated_cost, 0, '', 1, -1, 2), 'current_cost_for_to_make' => price($assetOf->current_cost_for_to_make, 0, '', 1, -1, 2)), 'view' => array('mode' => $mode, 'status' => $assetOf->status, 'allow_delete_of_finish' => $user->rights->of->of->allow_delete_of_finish, 'ASSET_USE_MOD_NOMENCLATURE' => (int) $conf->nomenclature->enabled, 'OF_MINIMAL_VIEW_CHILD_OF' => (int) $conf->global->OF_MINIMAL_VIEW_CHILD_OF, 'select_product' => $select_product, 'select_workstation' => $form->combo('', 'fk_asset_workstation', TWorkstation::getWorstations($PDOdb), -1), 'actionChild' => $mode == 'edit' ? __get('actionChild', 'edit') : __get('actionChild', 'view'), 'use_lot_in_of' => (int) (!empty($conf->asset->enabled) && !empty($conf->global->USE_LOT_IN_OF)), 'use_project_task' => (int) $conf->global->ASSET_USE_PROJECT_TASK, 'defined_user_by_workstation' => (int) $conf->global->ASSET_DEFINED_USER_BY_WORKSTATION, 'defined_task_by_workstation' => (int) $conf->global->ASSET_DEFINED_OPERATION_BY_WORKSTATION, 'defined_workstation_by_needed' => (int) $conf->global->ASSET_DEFINED_WORKSTATION_BY_NEEDED, 'defined_manual_wharehouse' => (int) $conf->global->ASSET_MANUAL_WAREHOUSE, 'hasChildren' => (int) (!empty($Tid)), 'user_id' => $user->id, 'workstation_module_activate' => (int) $conf->workstation->enabled, 'show_cost' => (int) $user->rights->of->of->price), 'rights' => array('show_ws_time' => $user->rights->of->of->show_ws_time))); echo $form->end_form(); llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $'); }
$tasktmp->label = $obj->label; print $tasktmp->getNomUrl(1, 'withproject', 'task', 1, '<br>'); } else { print $langs->trans("NoTasks"); } print '</td>'; print '<td align="center">' . dol_print_date($db->jdate($obj->dateo), 'day') . '</td>'; print '<td align="center">' . dol_print_date($db->jdate($obj->datee), 'day') . '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $obj->taskid . '&withproject=1">'; print convertSecondToTime($obj->planned_workload, 'allhourmin'); print '</a></td>'; print '<td align="right">'; print $obj->taskid > 0 ? $obj->progress . '%' : ''; print '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $obj->taskid . '&withproject=1">'; print convertSecondToTime($obj->timespent, 'allhourmin'); print '</a></td>'; print '<td align="right">'; if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload) . '%'; } } print $percentcompletion; print '</td>'; print "</tr>\n"; $i++; } if ($num > $max) {
} else { print ' '; } print '</td></tr>'; } // Date start print '<tr><td>' . $langs->trans("DateStart") . '</td><td colspan="3">'; print dol_print_date($object->date_start, 'dayhour'); print '</td></tr>'; // Date end print '<tr><td>' . $langs->trans("DateEnd") . '</td><td colspan="3">'; print dol_print_date($object->date_end, 'dayhour'); print '</td></tr>'; // Planned workload print '<tr><td>' . $langs->trans("PlannedWorkload") . '</td><td colspan="3">'; print convertSecondToTime($object->planned_workload, 'allhourmin'); print '</td></tr>'; // Progress declared print '<tr><td>' . $langs->trans("ProgressDeclared") . '</td><td colspan="3">'; print $object->progress . ' %'; print '</td></tr>'; // Progress calculated print '<tr><td>' . $langs->trans("ProgressCalculated") . '</td><td colspan="3">'; if ($object->planned_workload) { $tmparray = $object->getSummaryOfTimeSpent(); if ($tmparray['total_duration'] > 0) { print round($tmparray['total_duration'] / $object->planned_workload * 100, 2) . ' %'; } else { print '0 %'; } } else {
print '</td></tr>'; } } // Civility print '<tr><td>' . $langs->trans("UserTitle") . '</td><td colspan="3">'; print $object->getCivilityLabel(); print '</td></tr>'; // Date To Birth print '<tr>'; if (!empty($object->birthday)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; print '<td>' . $langs->trans("DateToBirth") . '</td><td colspan="3">' . dol_print_date($object->birthday, "day"); print ' '; //var_dump($birthdatearray); $ageyear = convertSecondToTime($now - $object->birthday, 'year') - 1970; $agemonth = convertSecondToTime($now - $object->birthday, 'month') - 1; if ($ageyear >= 2) { print '(' . $ageyear . ' ' . $langs->trans("DurationYears") . ')'; } else { if ($agemonth >= 2) { print '(' . $agemonth . ' ' . $langs->trans("DurationMonths") . ')'; } else { print '(' . $agemonth . ' ' . $langs->trans("DurationMonth") . ')'; } } print ' - '; if ($object->birthday_alert) { print $langs->trans("BirthdayAlertOn"); } else { print $langs->trans("BirthdayAlertOff"); }
} $var = true; while ($i < $num) { $objp = $db->fetch_object($resql); $var = !$var; // Ligne en mode visu if ($action != 'editline' || GETPOST('line_id', 'int') != $objp->rowid) { print '<tr ' . $bc[$var] . '>'; print '<td>'; print '<a name="' . $objp->rowid . '"></a>'; // ancre pour retourner sur la ligne print dol_htmlentitiesbr($objp->description); // Date print '<td align="center" width="150">' . dol_print_date($db->jdate($objp->date_intervention), 'dayhour') . '</td>'; // Duration print '<td align="right" width="150">' . convertSecondToTime($objp->duree) . '</td>'; print "</td>\n"; // Icone d'edition et suppression if ($object->statut == 0 && $user->rights->ficheinter->creer) { print '<td align="center">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=editline&line_id=' . $objp->rowid . '#' . $objp->rowid . '">'; print img_edit(); print '</a>'; print '</td>'; print '<td align="center">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=ask_deleteline&line_id=' . $objp->rowid . '">'; print img_delete(); print '</a></td>'; if ($num > 1) { print '<td align="center">'; if ($i > 0) {
/** * Fonction generant le projet sur le disque * * @param Project $object Object project a generer * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ function write_file($object, $outputlangs) { global $conf, $hookmanager, $langs, $user; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("projects"); if ($conf->projet->dir_output) { //$nblignes = count($object->lines); // This is set later with array of tasks $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->projet->dir_output; if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Complete object by loading several other informations $task = new Task($this->db); $tasksarray = $task->getTasksArray(0, 0, $object->id); if (!$object->id > 0) { $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray))); } $object->lines = $tasksarray; $nblignes = count($object->lines); $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Project")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Project")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 50; $tab_height = 200; $tab_top_newpage = 40; $tab_height_newpage = 210; // Affiche notes if (!empty($object->note_public)) { $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxref - 1, $tab_top - 2, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - ($tab_top - 2); // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 3, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; // Boucle sur les lignes for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; // Description of ligne $ref = $object->lines[$i]->ref; $libelleline = $object->lines[$i]->label; $progress = $object->lines[$i]->progress . '%'; $datestart = dol_print_date($object->lines[$i]->date_start, 'day'); $dateend = dol_print_date($object->lines[$i]->date_end, 'day'); $planned_workload = convertSecondToTime($object->lines[$i]->planned_workload, 'allhourmin'); $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->convToOutputCharset($ref), 0, 'L'); $pdf->SetXY($this->posxlabel, $curY); $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); $pdf->SetXY($this->posxworkload, $curY); $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $planned_workload, 0, 'R'); $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, $progress, 0, 'R'); $pdf->SetXY($this->posxdatestart, $curY); $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C'); $pdf->SetXY($this->posxdateend, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C'); $pageposafter = $pdf->getPage(); $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash' => 0)); } $nexY += 2; // Passe espace entre les lignes // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } /* * Pied de page */ $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $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)); } return 1; // Pas d'erreur } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR"); return 0; }
/** * Function to show a form to select a duration on a page * * @param string $prefix Prefix * @param int $iSecond Default preselected duration (number of seconds) * @param int $disabled Disable the combo box * @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo * @param string $minunderhours If 1, show minutes selection under the hours * @return void */ function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0) { global $langs; $hourSelected = 0; $minSelected = 0; if ($iSecond) { require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $hourSelected = convertSecondToTime($iSecond, 'allhour'); $minSelected = convertSecondToTime($iSecond, 'min'); } if ($typehour == 'select') { print '<select class="flat" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($hour = 0; $hour < 25; $hour++) { print '<option value="' . $hour . '"'; if ($hourSelected == $hour) { print " selected=\"true\""; } print ">" . $hour . "</option>"; } print "</select>"; } elseif ($typehour == 'text') { print '<input type="text" size="3" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="disabled"' : '') . ' class="flat" value="' . (int) $hourSelected . '">'; } print $langs->trans('Hours'); if ($minunderhours) { print '<br>'; } else { print " "; } print '<select class="flat" name="' . $prefix . 'min"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($min = 0; $min <= 55; $min = $min + 5) { print '<option value="' . $min . '"'; if ($minSelected == $min) { print ' selected="selected"'; } print '>' . $min . '</option>'; } print "</select>"; print $langs->trans('Minutes') . " "; }
{ print $fullhour; // TODO Add delay taking account of working hours per day and working day per week //if ($workingdelay != $fullhour) print '<br>('.$workingdelay.')'; } //else print '--:--'; print '</td>'; } // Time spent if (! empty($arrayfields['t.duration_effective']['checked'])) { $showlineingray=0;$showproject=1; print '<td class="center">'; if ($showlineingray) print '<i>'; else print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.($showproject?'':'&withproject=1').'">'; if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); else print '--:--'; if ($showlineingray) print '</i>'; else print '</a>'; print '</td>'; } // Calculated progress if (! empty($arrayfields['t.progress_calculated']['checked'])) { print '<td class="center">'; if ($obj->planned_workload || $obj->duration_effective) { if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %'; else print $langs->trans('WorkloadNotDefined'); } print '</td>';
$sql.= " AND p.rowid in (".$projectsListId.")"; $sql.= " GROUP BY p.rowid, p.ref, p.title"; $var=false; $resql = $db->query($sql); if ( $resql ) { while ($row = $db->fetch_object($resql)) { print "<tr $bc[$var]>"; print '<td>'; $projectstatic->id=$row->rowid; $projectstatic->ref=$row->ref; print $projectstatic->getNomUrl(1); print '</td>'; print '<td align="right">'.convertSecondToTime($row->nb).'</td>'; print "</tr>\n"; $var=!$var; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; print '</td></tr></table>'; llxFooter();
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '">'; } else { if ($user->rights->projet->creer) { print ' '; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=editline&lineid=' . $task_time->rowid . ($withproject ? '&withproject=1' : '') . '">'; print img_edit(); print '</a>'; print ' '; print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=deleteline&lineid=' . $task_time->rowid . ($withproject ? '&withproject=1' : '') . '">'; print img_delete(); print '</a>'; } } print '</td>'; print "</tr>\n"; $total += $task_time->task_duration; $totalvalue += price2num($task_time->thm * $task_time->task_duration / 3600); } print '<tr class="liste_total"><td colspan="3" class="liste_total">' . $langs->trans("Total") . '</td>'; print '<td align="right" class="nowrap liste_total">' . convertSecondToTime($total, 'allhourmin') . '</td>'; if ($conf->salaries->enabled) { print '<td align="right">' . price($totalvalue, 1, $langs, 1, -1, -1, $conf->currency) . '</td>'; } print '<td> </td>'; print '</tr>'; print "</table>"; print "</form>"; } } llxFooter(); $db->close();
/** * Output a task line into a perday intput mode * * @param string $inc Line number (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined * @param string $parent Id of parent project to show (0 to show all) * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $projectsrole Array of roles user has on project * @param string $tasksrole Array of roles user has on task * @param string $mine Show only task lines I am assigned to * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @return $inc */ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask = 1) { global $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic; $lastprojectid = 0; $var = true; $numlines = count($lines); for ($i = 0; $i < $numlines; $i++) { if ($parent == 0) { $level = 0; } if ($lines[$i]->fk_parent == $parent) { // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; $lastprojectid = $lines[$i]->fk_project; $projectstatic->id = $lines[$i]->fk_project; $projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTaks for all day of a week } // If we want all or we have a role on task, we show it if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { print "<tr " . $bc[$var] . ">\n"; // Project print '<td class="nowrap">'; $projectstatic->id = $lines[$i]->fk_project; $projectstatic->ref = $lines[$i]->projectref; $projectstatic->title = $lines[$i]->projectlabel; $projectstatic->public = $lines[$i]->public; print $projectstatic->getNomUrl(1, '', 0, $langs->transnoentitiesnoconv("YourRole") . ': ' . $projectsrole[$lines[$i]->fk_project]); print "</td>"; // Ref print '<td class="nowrap">'; $taskstatic->id = $lines[$i]->id; $taskstatic->ref = $lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id; print $taskstatic->getNomUrl(1, 'withproject', 'time'); print '</td>'; // Label task print "<td>"; print '<!-- Task id = ' . $lines[$i]->id . ' -->'; for ($k = 0; $k < $level; $k++) { print " "; } $taskstatic->id = $lines[$i]->id; $taskstatic->ref = $lines[$i]->label; $taskstatic->date_start = $lines[$i]->date_start; $taskstatic->date_end = $lines[$i]->date_end; print $taskstatic->getNomUrl(0, 'withproject', 'time'); //print "<br>"; //for ($k = 0 ; $k < $level ; $k++) print " "; //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "</td>\n"; // Planned Workload print '<td align="right">'; if ($lines[$i]->planned_workload) { print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); } else { print '--:--'; } print '</td>'; // Progress declared % print '<td align="right">'; print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress'); print '</td>'; // Time spent by everybody print '<td align="right">'; // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user if ($lines[$i]->duration) { print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $lines[$i]->id . '">'; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print '</a>'; } else { print '--:--'; } print "</td>\n"; // Time spent by user print '<td align="right">'; $tmptimespent = $taskstatic->getSummaryOfTimeSpent(); if ($tmptimespent['total_duration']) { print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); } else { print '--:--'; } print "</td>\n"; $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } //var_dump($projectstatic->weekWorkLoadPerTask); // Fields to show current time $tableCell = ''; $modeinput = 'hours'; for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $tmparray = dol_getdate($tmpday); $dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id]; $alreadyspent = ''; if ($dayWorkLoad > 0) { $alreadyspent = convertSecondToTime($dayWorkLoad, 'allhourmin'); } $tableCell = '<td align="center">'; $tableCell .= '<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent[' . $inc . '][' . $idw . ']" name="task[' . $lines[$i]->id . '][' . $idw . ']" value="' . $alreadyspent . '"></span>'; //$placeholder=' placeholder="00:00"'; $placeholder = ''; //if (! $disabledtask) //{ $tableCell .= '+'; $tableCell .= '<input type="text" alt="' . $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']) . '" title="' . $langs->trans("AddHereTimeSpentForDay", $tmparray['day'], $tmparray['mon']) . '" ' . ($disabledtask ? 'disabled' : $placeholder) . ' class="center" size="2" id="timeadded[' . $inc . '][' . $idw . ']" name="task[' . $lines[$i]->id . '][' . $idw . ']" value="" cols="2" maxlength="5"'; $tableCell .= ' onkeypress="return regexEvent(this,event,\'timeChar\')"'; $tableCell .= 'onblur="regexEvent(this,event,\'' . $modeinput . '\'); updateTotal(' . $idw . ',\'' . $modeinput . '\')" />'; //} $tableCell .= '</td>'; print $tableCell; } print '<td align="right">'; if (!$lines[$i]->public && $disabledproject) { print $form->textwithpicto('', $langs->trans("YouAreNotContactOfProject")); } else { if ($disabledtask) { print $form->textwithpicto('', $langs->trans("TaskIsNotAffectedToYou")); } } print '</td>'; print "</tr>\n"; } $inc++; $level++; if ($lines[$i]->id) { projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask); } $level--; } else { //$level--; } } return $inc; }
/** * Function to show a form to select a duration on a page * * @param string $prefix prefix * @param int $iSecond Default preselected duration (number of seconds) * @param int $disabled Disable the combo box * @return void */ function select_duration($prefix, $iSecond = '', $disabled = 0) { if ($iSecond) { require_once DOL_DOCUMENT_ROOT . "/core/lib/date.lib.php"; $hourSelected = convertSecondToTime($iSecond, 'hour'); $minSelected = convertSecondToTime($iSecond, 'min'); } print '<select class="flat" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($hour = 0; $hour < 24; $hour++) { print '<option value="' . $hour . '"'; if ($hourSelected == $hour) { print " selected=\"true\""; } print ">" . $hour . "</option>"; } print "</select>"; print "H "; print '<select class="flat" name="' . $prefix . 'min"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($min = 0; $min <= 55; $min = $min + 5) { print '<option value="' . $min . '"'; if ($minSelected == $min) { print ' selected="selected"'; } print '>' . $min . '</option>'; } print "</select>"; print "M "; }
function _task(&$db, $id_task, $values = array()) { global $user, $langs, $conf; $task = new Task($db); if ($id_task) { $task->fetch($id_task); $task->fetch_optionals($id_task); } if (!empty($values)) { _set_values($task, $values); if ($values['status'] == 'inprogress') { if ($task->progress == 0) { $task->progress = 5; } else { if ($task->progress == 100) { $task->progress = 95; } } } else { if ($values['status'] == 'finish') { $task->progress = 100; } else { if ($values['status'] == 'todo') { $task->progress = 0; } } } $task->status = $values['status']; $task->update($user); } $task->date_delivery = 0; if ($task->date_end > 0 && $task->planned_workload > 0) { $velocity = scrum_getVelocity($db, $task->fk_project); $task->date_delivery = _get_delivery_date_with_velocity($db, $task, $velocity); } $dayInSecond = 86400; if ($conf->global->TIMESHEET_WORKING_HOUR_PER_DAY) { $dayInSecond = 60 * 60 * $conf->global->TIMESHEET_WORKING_HOUR_PER_DAY; } $task->aff_time = convertSecondToTime($task->duration_effective, 'all', $dayInSecond); $task->aff_planned_workload = convertSecondToTime($task->planned_workload, 'all', $dayInSecond); $task->time_rest = $task->planned_workload * (1 - $task->progress / 100); $task->aff_time_rest = $langs->trans('TimeRest') . ' : ' . convertSecondToTime($task->time_rest, 'all', $dayInSecond); $task->long_description = $task->divers = ''; if ((int) $task->array_options['options_fk_of'] > 0 && $conf->of->enabled) { if (!isset($PDOdb)) { $PDOdb = new TPDOdb(); } $of = new TAssetOF(); $of->withChild = false; $of->load($PDOdb, $task->array_options['options_fk_of']); $link_of = !empty($conf->of->enabled) ? dol_buildpath('/of/fiche_of.php?id=' . $task->array_options['options_fk_of'], 1) : ''; if ($of->fk_soc > 0) { $soc = new Societe($db); $soc->fetch($of->fk_soc); } $task->divers .= '[<a href="' . $link_of . '">' . $of->numero . '</a>] ' . (!empty($soc) ? $soc->getNomUrl() : '') . '<br />'; if ($of->fk_commande > 0) { dol_include_once('/commande/class/commande.class.php'); $commande = new Commande($db); $commande->fetch($of->fk_commande); $task->divers .= $commande->getNomUrl(1) . '<br />'; } } if ((int) $task->array_options['options_fk_product'] > 0 && (empty($conf->global->SCRUMBOARD_ICON_SET) || $conf->global->SCRUMBOARD_ICON_SET != 'null')) { dol_include_once('/product/class/product.class.php'); $product = new Product($db); if ($product->fetch((int) $task->array_options['options_fk_product']) > 0) { $task->divers .= '[' . $product->getNomUrl() . ' ' . $product->label . ']<br />'; $nb_picto = $product->id % 49 - 1; $y_picto = floor($nb_picto / 7); $x_picto = $nb_picto - $y_picto * 7; $w_cell = 27; $h_cell = 28; $task->divers .= '<div class="picto" style="float:left; margin-left:3px; background-image:url(./img/' . (!empty($conf->global->SCRUMBOARD_ICON_SET) ? $conf->global->SCRUMBOARD_ICON_SET : 'animal-icons-mini') . '.png);background-position:' . $w_cell * -$x_picto . 'px ' . $h_cell * -$y_picto . 'px;width:' . $w_cell . 'px; height:' . $h_cell . 'px;"></div>'; //var_dump(array($nb_picto,$y_picto, $x_picto,$task->divers)); } } if (!empty($task->note_private)) { $task->divers .= '<br />' . $task->note_private; } if ($task->date_start > 0) { $task->long_description .= $langs->trans('TaskDateStart') . ' : ' . dol_print_date($task->date_start) . '<br />'; } if ($task->date_end > 0) { $task->long_description .= $langs->trans('TaskDateEnd') . ' : ' . dol_print_date($task->date_end) . '<br />'; } if ($task->date_delivery > 0 && $task->date_delivery > $task->date_end) { $task->long_description .= $langs->trans('TaskDateShouldDelivery') . ' : ' . dol_print_date($task->date_delivery) . '<br />'; } $task->long_description .= $task->description; $task->project = new Project($db); $task->project->fetch($task->fk_project); $task->project->fetch_optionals($task->fk_project, 'color'); if (!empty($conf->global->SCRUM_SHOW_LINKED_CONTACT)) { getTContact($task); } return _as_array($task); }
/** * Output a task line * * @param string $inc ? * @param string $parent ? * @param Object $lines ? * @param int $level ? * @param string $projectsrole ? * @param string $tasksrole ? * @param string $mine Show only task lines I am assigned to * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to * @return $inc */ function projectLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask = 0) { global $user, $bc, $langs; global $form, $projectstatic, $taskstatic; $lastprojectid = 0; $var = true; $numlines = count($lines); for ($i = 0; $i < $numlines; $i++) { if ($parent == 0) { $level = 0; } if ($lines[$i]->fk_parent == $parent) { // Break on a new project if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) { $var = !$var; $lastprojectid = $lines[$i]->fk_project; } // If we want all or we have a role on task, we show it if (empty($mine) || !empty($tasksrole[$lines[$i]->id])) { print "<tr " . $bc[$var] . ">\n"; // Project print "<td>"; $projectstatic->id = $lines[$i]->fk_project; $projectstatic->ref = $lines[$i]->projectref; $projectstatic->public = $lines[$i]->public; $projectstatic->label = $langs->transnoentitiesnoconv("YourRole") . ': ' . $projectsrole[$lines[$i]->fk_project]; print $projectstatic->getNomUrl(1); print "</td>"; // Ref print '<td>'; $taskstatic->id = $lines[$i]->id; $taskstatic->ref = $lines[$i]->id; print $taskstatic->getNomUrl(1); print '</td>'; // Label task print "<td>"; for ($k = 0; $k < $level; $k++) { print " "; } $taskstatic->id = $lines[$i]->id; $taskstatic->ref = $lines[$i]->label; print $taskstatic->getNomUrl(0); print "</td>\n"; // Date start print '<td align="center">'; print dol_print_date($lines[$i]->date_start, 'dayhour'); print '</td>'; // Date end print '<td align="center">'; print dol_print_date($lines[$i]->date_end, 'dayhour'); print '</td>'; // Planned Workload print '<td align="right">'; if ($lines[$i]->planned_workload) { print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); } else { print '--:--'; } print '</td>'; // Progress declared % print '<td align="right">'; print $lines[$i]->progress . ' %'; print '</td>'; // Time spent print '<td align="right">'; if ($lines[$i]->duration) { print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $lines[$i]->id . '">'; print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print '</a>'; } else { print '--:--'; } print "</td>\n"; $disabledproject = 1; $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); // If at least one role for project if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer) { $disabledproject = 0; $disabledtask = 0; } // If $restricteditformytask is on and I have no role on task, i disable edit if ($restricteditformytask && empty($tasksrole[$lines[$i]->id])) { $disabledtask = 1; } print '<td class="nowrap">'; $s = $form->select_date('', $lines[$i]->id, '', '', '', "addtime", 1, 0, 1, $disabledtask); $s .= ' '; $s .= $form->select_duration($lines[$i]->id, '', $disabledtask, 'text'); $s .= ' <input type="submit" class="button"' . ($disabledtask ? ' disabled="disabled"' : '') . ' value="' . $langs->trans("Add") . '">'; print $s; print '</td>'; print '<td align="right">'; if (!$lines[$i]->public && $disabledproject) { print $form->textwithpicto('', $langs->trans("YouAreNotContactOfProject")); } else { if ($disabledtask) { print $form->textwithpicto('', $langs->trans("TaskIsNotAffectedToYou")); } } print '</td>'; print "</tr>\n"; } $inc++; $level++; if ($lines[$i]->id) { projectLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask); } $level--; } else { //$level--; } } return $inc; }
if ($num > 0) { print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastInterventions", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/fichinter/list.php?socid=' . $object->id . '">' . $langs->trans("AllInterventions") . ' <span class="badge">' . $num . '</span></td></tr></table></td>'; print '</tr>'; $var = !$var; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $fichinter_static->id = $objp->id; $fichinter_static->statut = $objp->fk_statut; print "<tr " . $bc[$var] . ">"; print '<td class="nowrap"><a href="' . DOL_URL_ROOT . '/fichinter/card.php?id=' . $objp->id . '">' . img_object($langs->trans("ShowPropal"), "propal") . ' ' . $objp->ref . '</a></td>' . "\n"; //print '<td align="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n"; print '<td align="right" style="min-width: 60px">' . convertSecondToTime($objp->duration) . '</td>' . "\n"; print '<td align="right" class="nowrap" style="min-width: 60px">' . $fichinter_static->getLibStatut(5) . '</td>' . "\n"; print '</tr>'; $var = !$var; $i++; } $db->free($resql); if ($num > 0) { print "</table>"; } } else { dol_print_error($db); } } /* * Last invoices
/** * Function to build pdf onto disk * * @param object $object Object to generate * @param object $outputlangs Lang output object * @return int 1=ok, 0=ko */ function write_file($object, $outputlangs) { global $user, $langs, $conf, $mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("interventions"); if ($conf->ficheinter->dir_output) { $object->fetch_thirdparty(); $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->ficheinter->dir_output; if (!preg_match('/specimen/i', $objectref)) { $dir .= "/" . $objectref; } $file = $dir . "/" . $objectref . ".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $outputlangs->trans("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { $pdf = pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("InterventionCard")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("InterventionCard")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetAutoPageBreak(1, 0); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $tab_top = 100; $tab_top_middlepage = 50; $tab_top_newpage = 50; $tab_height = 120; $tab_height_newpage = 150; $tab_height_middlepage = 200; $tab_height_endpage = 170; // Affiche notes if (!empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190, 8, $outputlangs->transnoentities("Description"), 0, 'L', 0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur - $this->marge_droite, $tab_top + 8); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetXY($this->marge_gauche, $tab_top + 8); $text = $object->description; if ($object->duree > 0) { $totaltime = convertSecondToTime($object->duree, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); $text .= ($text ? ' - ' : '') . $langs->trans("Total") . ": " . $totaltime; } $desc = dol_htmlentitiesbr($text, 1); //print $outputlangs->convToOutputCharset($desc); exit; $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1); $nexY = $pdf->GetY(); $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->MultiCell(0, 2, ''); // Set interline to 3. Then writeMultiCell must use 3 also. $nblines = count($object->lines); // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $objectligne = $object->lines[$i]; $valide = $objectligne->id ? $objectligne->fetch($objectligne->id) : 0; if ($valide > 0 || $object->specimen) { $curY = $nexY; $pdf->SetFont('', 'B', $default_font_size - 1); $pdf->SetXY($this->marge_gauche, $curY); $txt = dol_htmlentitiesbr($outputlangs->transnoentities("Date") . " : " . dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true) . " - " . $outputlangs->transnoentities("Duration") . " : " . convertSecondToTime($objectligne->duration), 1, $outputlangs->charset_output); $curYold = $nexYold = $nexY; $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY, $txt, 0, 1, 0); $curY = $pdf->GetY(); $nexY += 3; $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->marge_gauche, $nexY); $desc = dol_htmlentitiesbr($objectligne->desc, 1); $curYold = $pdf->GetY(); $nexYold = $curYold; $pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY, $desc, 0, 1, 0); $stringheight = $pdf->getStringHeight('A', $txt); $curY = $pdf->GetY(); $nexY += dol_nboflines_bis($objectligne->desc, 0, $outputlangs->charset_output) * $stringheight; //print $curYold."-".$nexYold." +".dol_nboflines_bis($objectligne->desc,52,$outputlangs->charset_output)."*".$stringheight."= ".$curY."-".$nexY."<br>"; $nexY += 2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblines - 1 && empty($hidedesc)) { //on recupere la description du produit suivant $follow_descproduitservice = $objectligne->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 3; } else { $nblineFollowDesc = 0; } // Test if a new page is required if ($pagenb == 1) { $tab_top_in_current_page = $tab_top; $tab_height_in_current_page = $tab_height; } else { $tab_top_in_current_page = $tab_top_newpage; $tab_height_in_current_page = $tab_height_middlepage; } if ($nexY + $nblineFollowDesc > $tab_top_in_current_page + $tab_height_in_current_page && $i < $nblines - 1) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs); } $this->_pagefoot($pdf, $object, $outputlangs); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $nexY = $tab_top_newpage + 7; } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $bottomlasttab = $tab_top + $tab_height + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $bottomlasttab = $tab_top_newpage + $tab_height_newpage + 1; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file, 'F'); if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
$sql .= " AND tt.fk_task = t.rowid"; $sql .= " AND tt.fk_user = "******" AND YEAR(task_date) = '" . strftime("%Y", $now) . "'"; $sql .= " AND p.rowid in (" . $projectsListId . ")"; $sql .= " GROUP BY p.rowid, p.ref, p.title"; $var = false; $resql = $db->query($sql); if ($resql) { while ($row = $db->fetch_object($resql)) { print "<tr " . $bc[$var] . ">"; print '<td>'; $projectstatic->id = $row->rowid; $projectstatic->ref = $row->ref; print $projectstatic->getNomUrl(1); print '</td>'; print '<td align="right">' . convertSecondToTime($row->nb) . '</td>'; print "</tr>\n"; $var = !$var; } $db->free($resql); } else { dol_print_error($db); } print '<tr class="liste_total">'; print '<td>' . $langs->trans('Total') . '</td>'; print '<td align="right">' . convertSecondToTime($total) . '</td>'; print "</tr>\n"; print "</table>"; print '</div></div></div>'; llxFooter(); $db->close();
/** * Define array with couple substitution key => substitution value * * @param object $tasktime times object * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ function get_substitutionarray_taskstime($tasktime, $outputlangs) { global $conf; return array('tasktime_rowid' => $tasktime['rowid'], 'tasktime_task_date' => dol_print_date($tasktime['task_date'], 'day'), 'tasktime_task_duration' => convertSecondToTime($tasktime['task_duration'], 'all'), 'tasktime_note' => $tasktime['note'], 'tasktime_fk_user' => $tasktime['fk_user'], 'tasktime_user_name' => $tasktime['name'], 'tasktime_user_first' => $tasktime['firstname'], 'tasktime_fullcivname' => $tasktime['fullcivname']); }
/** * Function to show a form to select a duration on a page * * @param string $prefix Prefix for input fields * @param int $iSecond Default preselected duration (number of seconds) * @param int $disabled Disable the combo box * @param string $typehour If 'select' then input hour and input min is a combo, if 'text' input hour is in text and input min is a combo * @param string $minunderhours If 1, show minutes selection under the hours * @param int $nooutput Do not output html string but return it * @return void */ function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) { global $langs; $retstring = ''; $hourSelected = 0; $minSelected = 0; if ($iSecond) { require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $hourSelected = convertSecondToTime($iSecond, 'allhour'); $minSelected = convertSecondToTime($iSecond, 'min'); } if ($typehour == 'select') { $retstring .= '<select class="flat" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($hour = 0; $hour < 25; $hour++) { $retstring .= '<option value="' . $hour . '"'; if ($hourSelected == $hour) { $retstring .= " selected=\"true\""; } $retstring .= ">" . $hour . "</option>"; } $retstring .= "</select>"; } elseif ($typehour == 'text') { $retstring .= '<input type="text" size="2" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="disabled"' : '') . ' class="flat" value="' . ($hourSelected ? (int) $hourSelected : '') . '">'; } else { return 'BadValueForParameterTypeHour'; } $retstring .= ' ' . $langs->trans('HourShort'); if ($minunderhours) { $retstring .= '<br>'; } else { $retstring .= " "; } if ($typehour == 'select') { $retstring .= '<select class="flat" name="' . $prefix . 'min"' . ($disabled ? ' disabled="disabled"' : '') . '>'; for ($min = 0; $min <= 55; $min = $min + 5) { $retstring .= '<option value="' . $min . '"'; if ($minSelected == $min) { $retstring .= ' selected="selected"'; } $retstring .= '>' . $min . '</option>'; } $retstring .= "</select>"; } elseif ($typehour == 'text') { $retstring .= '<input type="text" size="2" name="' . $prefix . 'min"' . ($disabled ? ' disabled="disabled"' : '') . ' class="flat" value="' . ($minSelected ? (int) $minSelected : '') . '">'; } $retstring .= ' ' . $langs->trans('MinuteShort'); $retstring .= " "; if (!empty($nooutput)) { return $retstring; } print $retstring; return; }
/** * Build a file from an array of events * All input params and data must be encoded in $conf->charset_output * * @param string $format 'vcal' or 'ical' * @param string $title Title of export * @param string $desc Description of export * @param array $events_array Array of events ('eid','startdate','duration','enddate','title','summary','category','email','url','desc','author') * @param string $outputfile Output file * @return int <0 if ko, Nb of events in file if ok */ function build_calfile($format, $title, $desc, $events_array, $outputfile) { global $conf, $langs; dol_syslog("xcal.lib.php::build_calfile Build cal file " . $outputfile . " to format " . $format); if (empty($outputfile)) { return -1; } // Note: A cal file is an UTF8 encoded file $calfileh = fopen($outputfile, 'w'); if ($calfileh) { include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; $now = dol_now(); $encoding = ''; if ($format == 'vcal') { $encoding = 'ENCODING=QUOTED-PRINTABLE:'; } // Print header fwrite($calfileh, "BEGIN:VCALENDAR\n"); fwrite($calfileh, "VERSION:2.0\n"); fwrite($calfileh, "METHOD:PUBLISH\n"); //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n"); fwrite($calfileh, "PRODID:-//DOLIBARR " . DOL_VERSION . "\n"); fwrite($calfileh, "CALSCALE:GREGORIAN\n"); fwrite($calfileh, "X-WR-CALNAME:" . $encoding . format_cal($format, $title) . "\n"); fwrite($calfileh, "X-WR-CALDESC:" . $encoding . format_cal($format, $desc) . "\n"); $hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'hour'); $mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'min'); $ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'sec'); //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) { fwrite($calfileh, "X-PUBLISHED-TTL: P" . $hh . "H" . $mm . "M" . $ss . "S\n"); } foreach ($events_array as $date => $event) { $eventqualified = true; if ($eventqualified) { // See http://fr.wikipedia.org/wiki/ICalendar for format // See http://www.ietf.org/rfc/rfc2445.txt for RFC $uid = $event['uid']; $type = $event['type']; $startdate = $event['startdate']; $duration = $event['duration']; $enddate = $event['enddate']; $summary = $event['summary']; $category = $event['category']; $priority = $event['priority']; $fulldayevent = $event['fulldayevent']; $location = $event['location']; $email = $event['email']; $url = $event['url']; $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy) $description = preg_replace('/<br[\\s\\/]?>/i', "\n", $event['desc']); $description = dol_string_nohtmltag($description, 0); // Remove html tags $created = $event['created']; $modified = $event['modified']; // Uncomment for tests //$summary="Resume"; //$description="Description"; //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd"; // Format $summary = format_cal($format, $summary); $description = format_cal($format, $description); $category = format_cal($format, $category); $location = format_cal($format, $location); // Output the vCard/iCal VEVENT object /* Example from Google ical export for a 1 hour event: BEGIN:VEVENT DTSTART:20101103T120000Z DTEND:20101103T130000Z DTSTAMP:20101121T144902Z UID:4eilllcsq8r1p87ncg7vc8dbpk@google.com CREATED:20101121T144657Z DESCRIPTION: LAST-MODIFIED:20101121T144707Z LOCATION: SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Tache 1 heure TRANSP:OPAQUE END:VEVENT Example from Google ical export for a 1 day event: BEGIN:VEVENT DTSTART;VALUE=DATE:20101102 DTEND;VALUE=DATE:20101103 DTSTAMP:20101121T144902Z UID:d09t43kcf1qgapu9efsmmo1m6k@google.com CREATED:20101121T144607Z DESCRIPTION: LAST-MODIFIED:20101121T144607Z LOCATION: SEQUENCE:0 STATUS:CONFIRMED SUMMARY:Tache 1 jour TRANSP:TRANSPARENT END:VEVENT */ if ($type == 'event') { fwrite($calfileh, "BEGIN:VEVENT\n"); fwrite($calfileh, "UID:" . $uid . "\n"); if (!empty($email)) { fwrite($calfileh, "ORGANIZER:MAILTO:" . $email . "\n"); fwrite($calfileh, "CONTACT:MAILTO:" . $email . "\n"); } if (!empty($url)) { fwrite($calfileh, "URL:" . $url . "\n"); } if ($created) { fwrite($calfileh, "CREATED:" . dol_print_date($created, 'dayhourxcard', true) . "\n"); } if ($modified) { fwrite($calfileh, "LAST-MODIFIED:" . dol_print_date($modified, 'dayhourxcard', true) . "\n"); } fwrite($calfileh, "SUMMARY:" . $encoding . $summary . "\n"); fwrite($calfileh, "DESCRIPTION:" . $encoding . $description . "\n"); /* Other keys: // Status values for a "VEVENT" statvalue = "TENTATIVE" ;Indicates event is ;tentative. / "CONFIRMED" ;Indicates event is ;definite. / "CANCELLED" ;Indicates event was // Status values for "VTODO". statvalue =/ "NEEDS-ACTION" ;Indicates to-do needs action. / "COMPLETED" ;Indicates to-do completed. / "IN-PROCESS" ;Indicates to-do in process of / "CANCELLED" ;Indicates to-do was cancelled. // Status values for "VJOURNAL". statvalue =/ "DRAFT" ;Indicates journal is draft. / "FINAL" ;Indicates journal is final. / "CANCELLED" ;Indicates journal is removed. */ //fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:eldy10@gmail.com if (!empty($location)) { fwrite($calfileh, "LOCATION:" . $encoding . $location . "\n"); } if ($fulldayevent) { fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n"); } if ($fulldayevent) { fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); } // Date must be GMT dates // Current date fwrite($calfileh, "DTSTAMP:" . dol_print_date($now, 'dayhourxcard', true) . "\n"); // Start date $prefix = ''; $startdatef = dol_print_date($startdate, 'dayhourxcard', true); if ($fulldayevent) { $prefix = ';VALUE=DATE'; $startdatef = dol_print_date($startdate, 'dayxcard', false); // Local time } fwrite($calfileh, "DTSTART" . $prefix . ":" . $startdatef . "\n"); // End date if ($fulldayevent) { if (empty($enddate)) { $enddate = dol_time_plus_duree($startdate, 1, 'd'); } } else { if (empty($enddate)) { $enddate = $startdate + $duration; } } $prefix = ''; $enddatef = dol_print_date($enddate, 'dayhourxcard', true); if ($fulldayevent) { $prefix = ';VALUE=DATE'; $enddatef = dol_print_date($enddate + 1, 'dayxcard', false); //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time } fwrite($calfileh, "DTEND" . $prefix . ":" . $enddatef . "\n"); fwrite($calfileh, 'STATUS:CONFIRMED' . "\n"); if (!empty($transparency)) { fwrite($calfileh, "TRANSP:" . $transparency . "\n"); } if (!empty($category)) { fwrite($calfileh, "CATEGORIES:" . $encoding . $category . "\n"); } fwrite($calfileh, "END:VEVENT\n"); } // Output the vCard/iCal VTODO object // ... //PERCENT-COMPLETE:39 // Output the vCard/iCal VJOURNAL object if ($type == 'journal') { fwrite($calfileh, "BEGIN:VJOURNAL\n"); fwrite($calfileh, "UID:" . $uid . "\n"); if (!empty($email)) { fwrite($calfileh, "ORGANIZER:MAILTO:" . $email . "\n"); fwrite($calfileh, "CONTACT:MAILTO:" . $email . "\n"); } if (!empty($url)) { fwrite($calfileh, "URL:" . $url . "\n"); } if ($created) { fwrite($calfileh, "CREATED:" . dol_print_date($created, 'dayhourxcard', true) . "\n"); } if ($modified) { fwrite($calfileh, "LAST-MODIFIED:" . dol_print_date($modified, 'dayhourxcard', true) . "\n"); } fwrite($calfileh, "SUMMARY:" . $encoding . $summary . "\n"); fwrite($calfileh, "DESCRIPTION:" . $encoding . $description . "\n"); fwrite($calfileh, 'STATUS:CONFIRMED' . "\n"); fwrite($calfileh, "CATEGORIES:" . $category . "\n"); fwrite($calfileh, "LOCATION:" . $location . "\n"); fwrite($calfileh, "TRANSP:OPAQUE\n"); fwrite($calfileh, "CLASS:CONFIDENTIAL\n"); fwrite($calfileh, "DTSTAMP:" . dol_print_date($startdatef, 'dayhourxcard', true) . "\n"); fwrite($calfileh, "END:VJOURNAL\n"); } // Put other info in comment /* $comment=array(); $comment ['eid'] = $eid; $comment ['url'] = $linktoevent; $comment ['date'] = dol_mktime($evttime,"Ymd"); $comment ['duration'] = $duration; $comment ['startdate'] = $startdate; $comment ['enddate'] = $enddate; fwrite($calfileh,"COMMENT:" . serialize ($comment) . "\n"); */ } } // Footer fwrite($calfileh, "END:VCALENDAR"); fclose($calfileh); if (!empty($conf->global->MAIN_UMASK)) { @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); } } else { dol_syslog("xcal.lib.php::build_calfile Failed to open file " . $outputfile . " for writing"); return -2; } }
if ($num > 0) { print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastInterventions", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/fichinter/list.php?socid=' . $object->id . '">' . $langs->trans("AllInterventions") . ' (' . $num . ')</td></tr></table></td>'; print '</tr>'; $var = !$var; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $fichinter_static->id = $objp->id; $fichinter_static->statut = $objp->fk_statut; print "<tr " . $bc[$var] . ">"; print '<td nowrap="nowrap"><a href="' . DOL_URL_ROOT . '/fichinter/fiche.php?id=' . $objp->id . '">' . img_object($langs->trans("ShowPropal"), "propal") . ' ' . $objp->ref . '</a></td>' . "\n"; //print '<td align="right" width="80">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n"; print '<td align="right" width="120">' . convertSecondToTime($objp->duration) . '</td>' . "\n"; print '<td align="right" width="100">' . $fichinter_static->getLibStatut(5) . '</td>' . "\n"; print '</tr>'; $var = !$var; $i++; } $db->free($resql); if ($num > 0) { print "</table>"; } } else { dol_print_error($db); } } /* * Last invoices
/** * Function to build pdf onto disk * * @param Object $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) { $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("interventions"); if ($conf->ficheinter->dir_output) { $object->fetch_thirdparty(); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->ficheinter->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->ficheinter->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $nblignes = count($object->lines); // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("InterventionCard")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("InterventionCard")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetTextColor(0, 0, 0); $tab_top = 90; $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10; $tab_height = 130; $tab_height_newpage = 150; // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if ($notetoshow) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); $nexY = $pdf->GetY(); $height_note = $nexY - $tab_top; // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192, 192, 192); $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; } else { $height_note = 0; } $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0); $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($this->marge_gauche, $tab_top + 5); $text = $object->description; if ($object->duree > 0) { $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); $text .= ($text ? ' - ' : '') . $langs->trans("Total") . ": " . $totaltime; } $desc = dol_htmlentitiesbr($text, 1); //print $outputlangs->convToOutputCharset($desc); exit; $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1); $nexY = $pdf->GetY(); $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $nblines = count($object->lines); // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $objectligne = $object->lines[$i]; $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id); if ($valide > 0 || $object->specimen) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); // Description of product line $curX = $this->posxdesc - 1; // Description of product line $txt = $outputlangs->transnoentities("Date") . " : " . dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); if ($objectligne->duration > 0) { $txt .= " - " . $outputlangs->transnoentities("Duration") . " : " . convertSecondToTime($objectligne->duration); } $txt = '<strong>' . dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output) . '</strong>'; $desc = dol_htmlentitiesbr($objectligne->desc, 1); $pdf->startTransaction(); $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $pdf->writeHTMLCell(0, 0, $curX, $curY, $txt . '<br>' . $desc, LR, 1, 0); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { if ($i == $nblines - 1) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposafter + 1); } } } else { $pdf->commitTransaction(); } $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $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)); } return 1; } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * testConvertSecondToTime * * @return void */ public function testConvertSecondToTime() { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $result=convertSecondToTime(0,'all',86400); print __METHOD__." result=".$result."\n"; $this->assertEquals('0',$result); $result=convertSecondToTime(86400,'all',86400); print __METHOD__." result=".$result."\n"; $this->assertSame('1 '.$langs->trans("Day"),$result); return $result; }
$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>'; } print '</table>'; print "</form>\n"; $db->free($result); } else { dol_print_error($db); } $db->close(); llxFooter();
/** * Return HTML table with list of projects and number of opened tasks * * @param DoliDB $db Database handler * @param Form $form Object form * @param int $socid Id thirdparty * @param int $projectsListId Id of project I have permission on * @param int $mytasks Limited to task I am contact to * @param int $statut -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) * @return void */ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array()) { global $langs, $conf, $user, $bc; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $projectstatic = new Project($db); $thirdpartystatic = new Societe($db); $sortfield = ''; $sortorder = ''; $project_year_filter = 0; $title = $langs->trans("Projects"); if (strcmp($statut, '') && $statut >= 0) { $title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]); } $arrayidtypeofcontact = array(); print '<table class="noborder" width="100%">'; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; if ($mytasks) { $sql .= ", " . MAIN_DB_PREFIX . "projet_task as t"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec"; $sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.rowid IN (" . $projectsListId . ")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ec.fk_socpeople = " . $user->id; $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact $sql .= " AND ctc.element = 'project_task'"; } if ($statut >= 0) { $sql .= " AND p.fk_statut = " . $statut; } if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { $project_year_filter = GETPOST("project_year_filter"); //Check if empty or invalid year. Wildcard ignores the sql check if ($project_year_filter != "*") { if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { $project_year_filter = date("Y"); } $sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")"; $sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")"; } } // Get id of project we must show tasks $arrayidofprojects = array(); $sql1 = "SELECT p.rowid as projectid"; $sql1 .= $sql; $resql = $db->query($sql1); if ($resql) { $i = 0; $num = $db->num_rows($resql); while ($i < $num) { $objp = $db->fetch_object($resql); $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } } else { dol_print_error($db); } if (empty($arrayidofprojects)) { $arrayidofprojects[0] = -1; } // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; $sql2 .= " FROM " . MAIN_DB_PREFIX . "projet as p"; $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = p.fk_soc"; $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; $sql2 .= " WHERE p.rowid IN (" . join(',', $arrayidofprojects) . ")"; $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount"; $sql2 .= " ORDER BY p.title, p.ref"; $var = true; $resql = $db->query($sql2); if ($resql) { $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; $num = $db->num_rows($resql); $i = 0; print '<tr class="liste_titre">'; print_liste_field_titre($title . ' <span class="badge">' . $num . '</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdParty"), $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre($langs->trans("OpportunityAmount"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("OpportunityStatus"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder); if (!in_array('plannedworkload', $hiddenfields)) { print_liste_field_titre($langs->trans("PlannedWorkload"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } if (!in_array('declaredprogress', $hiddenfields)) { print_liste_field_titre($langs->trans("ProgressDeclared"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } } print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print "</tr>\n"; while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>'; $projectstatic->ref = $objp->ref; print $projectstatic->getNomUrl(1); if (!in_array('projectlabel', $hiddenfields)) { print ' - ' . dol_trunc($objp->title, 24); } print '</td>'; print '<td>'; if ($objp->fk_soc > 0) { $thirdpartystatic->id = $objp->fk_soc; $thirdpartystatic->ref = $objp->socname; $thirdpartystatic->name = $objp->socname; print $thirdpartystatic->getNomUrl(1); } print '</td>'; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td align="right">'; if ($objp->opp_amount) { print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); } print '</td>'; print '<td align="right">'; $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) { print $langs->trans("OppStatus" . $code); } print '</td>'; } $projectstatic->statut = $objp->status; if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td align="right">' . $objp->nb . '</td>'; $plannedworkload = $objp->planned_workload; $total_plannedworkload += $plannedworkload; if (!in_array('plannedworkload', $hiddenfields)) { print '<td align="right">' . ($plannedworkload ? convertSecondToTime($plannedworkload) : '') . '</td>'; } if (!in_array('declaredprogress', $hiddenfields)) { $declaredprogressworkload = $objp->declared_progess_workload; $total_declaredprogressworkload += $declaredprogressworkload; print '<td align="right">'; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; print $plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0) . '%' : ''; print '</td>'; } } print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>'; print "</tr>\n"; $total_task = $total_task + $objp->nb; $total_opp_amount = $total_opp_amount + $objp->opp_amount; $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100); } $i++; } print '<tr class="liste_total">'; print '<td colspan="2">' . $langs->trans("Total") . "</td>"; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td class="liste_total" align="right">' . price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency) . '</td>'; print '<td class="liste_total" align="right">' . $form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1) . '</td>'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td class="liste_total" align="right">' . $total_task . '</td>'; if (!in_array('plannedworkload', $hiddenfields)) { print '<td class="liste_total" align="right">' . ($total_plannedworkload ? convertSecondToTime($total_plannedworkload) : '') . '</td>'; } if (!in_array('declaredprogress', $hiddenfields)) { print '<td class="liste_total" align="right">' . ($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0) . '%' : '') . '</td>'; } } print '<td class="liste_total"></td>'; print '</tr>'; $db->free($resql); } else { dol_print_error($db); } print "</table>"; if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { //Add the year filter input print '<form method="get" action="' . $_SERVER["PHP_SELF"] . '">'; print '<table width="100%">'; print '<tr>'; print '<td>' . $langs->trans("Year") . '</td>'; print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="' . $project_year_filter . '"/>'; print "</tr>\n"; print '</table></form>'; } }
$tasktmp->ref = $obj->label; print $tasktmp->getNomUrl(1, 'withproject'); } else { print $langs->trans("NoTasks"); } print '</td>'; print '<td>' . dol_print_date($db->jdate($obj->dateo), 'day') . '</td>'; print '<td>' . dol_print_date($db->jdate($obj->datee), 'day') . '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $obj->taskid . '&withproject=1">'; print convertSecondToTime($obj->planned_workload, 'all'); print '</a></td>'; print '<td align="right">'; print $obj->taskid > 0 ? $obj->progress . '%' : ''; print '</td>'; print '<td align="right"><a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $obj->taskid . '&withproject=1">'; print convertSecondToTime($obj->timespent, 'all'); print '</a></td>'; print '<td align="right">'; if (!empty($obj->taskid)) { if (empty($obj->planned_workload) > 0) { $percentcompletion = $langs->trans("WorkloadNotDefined"); } else { $percentcompletion = intval($obj->duration_effective * 100 / $obj->planned_workload) . '%'; } } print $percentcompletion; print '</td>'; print "</tr>\n"; $i++; } if ($num > $max) {
function printRapport() { global $db; dol_include_once('/core/lib/date.lib.php'); $fk_statut = GETPOST("fk_statut"); ?> <style type="text/css"> table#rapport_depassement td,table#rapport_depassement th { white-space: nowrap; border-right: 1px solid #D8D8D8; border-bottom: 1px solid #D8D8D8; } </style> <div style="padding-bottom: 25px;"> <table id="rapport_depassement" class="noborder" width="100%"> <thead> <tr style="text-align:left;" class="liste_titre nodrag nodrop"> <th class="liste_titre">Projet</th> <th class="liste_titre">Société</th> <th class="liste_titre">Date début</th> <th class="liste_titre">Date Fin</th> <th class="liste_titre">Temps prévu</th> <th class="liste_titre">Temps passé</th> <th class="liste_titre">Dépassement</th> </tr> </thead> <tbody> <?php $TProjet = getProjectExceeded($fk_statut); $total_timespent = 0; $total_timeplanned = 0; $total_exceed = 0; foreach ($TProjet as $proj) { $total_timespent += $proj['timespent']; $total_timeplanned += $proj['timeplanned']; $total_exceed += $proj['exceed']; $projet = $proj['projet']; $societe = new Societe($db); $societe->fetch($projet->socid); ?> <tr> <td><?php echo $projet->getNomUrl(1); ?> </td> <td><?php echo $societe->getNomUrl(1); ?> </td> <td><?php echo date('d/m/Y', intval($projet->date_start)); ?> </td> <td><?php echo $projet->date_end != null ? date('d/m/Y', intval($projet->date_end)) : ""; ?> </td> <td <?php echo $proj['percentage'] < 100 ? ' style="color:#FF8000;font-weight: bold"" ' : ' style="color:red;font-weight: bold" '; ?> ><?php echo convertSecondToTime($proj['timeplanned']); ?> </td> <td <?php echo $proj['percentage'] < 100 ? ' style="color:#FF8000;font-weight: bold"" ' : ' style="color:red;font-weight: bold" '; ?> ><?php echo convertSecondToTime($proj['timespent']); ?> </td> <td <?php echo $proj['percentage'] < 100 ? ' style="color:#FF8000;font-weight: bold"" ' : ' style="color:red;font-weight: bold" '; ?> ><?php echo convertSecondToTime($proj['exceed']); ?> </td> </tr> <?php } ?> <tfoot> <tr style="font-weight: bold;"> <td>Totaux</td> <td></td> <td></td> <td></td> <td><?php echo convertSecondToTime($total_timeplanned); ?> </td> <td><?php echo convertSecondToTime($total_timespent); ?> </td> <td><?php echo convertSecondToTime($total_exceed); ?> </td> </tr> </tfoot> </tbody> </table> </div> <?php }