Пример #1
0
         $num = $db->num_rows($resql);
         if ($num > 0) {
             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/index.php?socid=' . $objsoc->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">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
             print '<td align="right">' . ConvertSecondToTime($objp->duration) . '</td>' . "\n";
             print '<td align="right">' . $fichinter_static->getLibStatut(3) . '</td>' . "\n";
             print '</tr>';
             $var = !$var;
             $i++;
         }
         $db->free($resql);
     } else {
         dol_print_error($db);
     }
     print "</table>";
 }
 /*
  *   Last invoices
  */
 if ($conf->facture->enabled && $user->rights->facture->lire) {
Пример #2
0
 /**
  *	Function to show a form to select a duration on a page
  *	@param		prefix   	prefix
  *	@param  	iSecond  	Default preselected duration (number of seconds)
  * 	@param		disabled	Disable the combo box
  */
 function select_duration($prefix, $iSecond = '', $disabled = 0)
 {
     if ($iSecond) {
         require_once DOL_DOCUMENT_ROOT . "/lib/date.lib.php";
         $hourSelected = ConvertSecondToTime($iSecond, 'hour');
         $minSelected = ConvertSecondToTime($iSecond, 'min');
     }
     print '<select class="flat" name="' . $prefix . 'hour"' . ($disabled ? ' disabled="true"' : '') . '>';
     for ($hour = 0; $hour < 24; $hour++) {
         print '<option value="' . $hour . '"';
         if ($hourSelected == $hour) {
             print " selected=\"true\"";
         }
         print ">" . $hour . "</option>";
     }
     print "</select>";
     print "H &nbsp;";
     print '<select class="flat" name="' . $prefix . 'min"' . ($disabled ? ' disabled="true"' : '') . '>';
     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&nbsp;";
 }
Пример #3
0
            $objp = $db->fetch_object($resql);
            $var=!$var;

            // Ligne en mode visu
            if ($action != 'editline' || $_GET['ligne'] != $objp->rowid)
            {
                print '<tr '.$bc[$var].'>';
                print '<td>';
                print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
                print nl2br($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.'&amp;action=editline&amp;ligne='.$objp->rowid.'#'.$objp->rowid.'">';
                    print img_edit();
                    print '</a>';
                    print '</td>';
                    print '<td align="center">';
                    print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=ask_deleteline&amp;ligne='.$objp->rowid.'">';
                    print img_delete();
Пример #4
0
/**
 * Show task lines with a particular parent
 * @param 	$inc				Counter that count number of lines legitimate to show (for return)
 * @param 	$parent				Id of parent task to start
 * @param 	$lines				Array of all tasks
 * @param 	$level				Level of task
 * @param 	$var				Color
 * @param 	$showproject		Show project columns
 * @param	$taskrole			Array of roles of user for each tasks
 * @param	$projectsListId		List of id of project allowed to user (separated with comma)
 */
function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '')
{
    global $user, $bc, $langs;
    $lastprojectid = 0;
    $projectstatic = new Project($db);
    $taskstatic = new Task($db);
    $projectsArrayId = explode(',', $projectsListId);
    $numlines = sizeof($lines);
    $total = 0;
    for ($i = 0; $i < $numlines; $i++) {
        if ($parent == 0) {
            $level = 0;
        }
        // Process line
        // print "i:".$i."-".$lines[$i]->fk_project.'<br>';
        if ($lines[$i]->fk_parent == $parent) {
            // Show task line.
            $showline = 1;
            $showlineingray = 0;
            // If there is filters to use
            if (is_array($taskrole)) {
                // If task not legitimate to show, search if a legitimate task exists later in tree
                if (!isset($taskrole[$lines[$i]->id]) && $lines[$i]->id != $lines[$i]->fk_parent) {
                    // So search if task has a subtask legitimate to show
                    $foundtaskforuserdeeper = 0;
                    SearchTaskInChild($foundtaskforuserdeeper, $lines[$i]->id, $lines, $taskrole);
                    //print '$foundtaskforuserpeeper='.$foundtaskforuserdeeper.'<br>';
                    if ($foundtaskforuserdeeper > 0) {
                        $showlineingray = 1;
                        // We will show line but in gray
                    } else {
                        $showline = 0;
                        // No reason to show line
                    }
                }
            }
            if ($showline) {
                // Break on a new project
                if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid) {
                    $var = !$var;
                    $lastprojectid = $lines[$i]->fk_project;
                }
                print "<tr " . $bc[$var] . ">\n";
                // Project
                if ($showproject) {
                    print "<td>";
                    //var_dump($taskrole);
                    if ($showlineingray) {
                        print '<i>';
                    }
                    $projectstatic->id = $lines[$i]->fk_project;
                    $projectstatic->ref = $lines[$i]->projectref;
                    $projectstatic->public = $lines[$i]->public;
                    if ($lines[$i]->public || in_array($lines[$i]->fk_project, $projectsArrayId)) {
                        print $projectstatic->getNomUrl(1);
                    } else {
                        print $projectstatic->getNomUrl(1, 'nolink');
                    }
                    if ($showlineingray) {
                        print '</i>';
                    }
                    print "</td>";
                }
                // Ref of task
                print '<td>';
                if ($showlineingray) {
                    print '<i>' . img_object('', 'projecttask') . ' ' . $lines[$i]->id . '</i>';
                } else {
                    $taskstatic->id = $lines[$i]->id;
                    $taskstatic->ref = $lines[$i]->id;
                    $taskstatic->label = $taskrole[$lines[$i]->id] ? $langs->trans("YourRole") . ': ' . $taskrole[$lines[$i]->id] : '';
                    print $taskstatic->getNomUrl(1);
                }
                print '</td>';
                // Title of task
                print "<td>";
                if ($showlineingray) {
                    print '<i>';
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/projet/tasks/task.php?id=' . $lines[$i]->id . '">';
                }
                for ($k = 0; $k < $level; $k++) {
                    print "&nbsp; &nbsp; &nbsp;";
                }
                print $lines[$i]->label;
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print "</td>\n";
                // Progress
                print '<td align="right">';
                print $lines[$i]->progress . ' %';
                print '</td>';
                // Time spent
                print '<td align="right">';
                if ($showlineingray) {
                    print '<i>';
                } else {
                    print '<a href="' . DOL_URL_ROOT . '/projet/tasks/time.php?id=' . $lines[$i]->id . '">';
                }
                if ($lines[$i]->duration) {
                    print ConvertSecondToTime($lines[$i]->duration, 'all');
                } else {
                    print '--:--';
                }
                if ($showlineingray) {
                    print '</i>';
                } else {
                    print '</a>';
                }
                print '</td>';
                print "</tr>\n";
                if (!$showlineingray) {
                    $inc++;
                }
                $level++;
                if ($lines[$i]->id) {
                    PLines($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId);
                }
                $level--;
                $total += $lines[$i]->duration;
            }
        } else {
            //$level--;
        }
    }
    if ($total > 0) {
        print '<tr class="liste_total"><td class="liste_total">' . $langs->trans("Total") . '</td>';
        print '<td></td>';
        print '<td></td>';
        print '<td align="right" nowrap="nowrap" class="liste_total">' . ConvertSecondToTime($total) . '</td></tr>';
    }
    return $inc;
}
Пример #5
0
/**
 *	Build a file from an array of events
 *  All input params and data must be encoded in $conf->charset_output
 *	@param		format				'vcal' or 'ical'
 *	@param		title				Title of export
 *	@param		desc				Description of export
 *	@param		events_array		Array of events ('eid','startdate','duration','enddate','title','summary','category','email','url','desc','author')
 *	@param		outputfile			Output file
 *	@return		int					<0 if ko, Nb of events in file if ok
 */
function build_calfile($format='vcal',$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.'/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;
	}
}
Пример #6
0
$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>';

$db->close();
Пример #7
0
 /**
  *  Load data for box to show them later
  *
  *  @param  int     $max        Maximum number of records to load
  *  @return void
  */
 function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     $this->max = $max;
     $totalMnt = 0;
     $totalnb = 0;
     $totalDuree = 0;
     include_once DOL_DOCUMENT_ROOT . "/projet/class/task.class.php";
     $taskstatic = new Task($db);
     $textHead = $langs->trans("Tasks") . "&nbsp;" . date("Y");
     $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead));
     // list the summary of the orders
     if ($user->rights->projet->lire) {
         $sql = "SELECT pt.fk_statut, count(pt.rowid) as nb, sum(ptt.task_duration) as durationtot, sum(pt.planned_workload) as plannedtot";
         $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt";
         $sql .= " WHERE pt.datec BETWEEN '" . $this->db->idate(dol_get_first_day(date("Y"), 1)) . "' AND '" . $this->db->idate(dol_get_last_day(date("Y"), 12)) . "'";
         $sql .= " AND pt.rowid = ptt.fk_task";
         $sql .= " GROUP BY pt.fk_statut ";
         $sql .= " ORDER BY pt.fk_statut DESC";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $langs->trans("Task") . " " . $taskstatic->LibStatut($objp->fk_statut, 0));
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => $objp->nb . "&nbsp;" . $langs->trans("Tasks"), 'url' => DOL_URL_ROOT . "/projet/tasks/list.php?leftmenu=projects&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => ConvertSecondToTime($objp->plannedtot, 'all', 25200, 5));
                 $totalplannedtot += $objp->plannedtot;
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => ConvertSecondToTime($objp->durationtot, 'all', 25200, 5));
                 $totaldurationtot += $objp->durationtot;
                 $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $taskstatic->LibStatut($objp->fk_statut, 3));
                 $i++;
             }
         } else {
             dol_print_error($this->db);
         }
     }
     // Add the sum à the bottom of the boxes
     $this->info_box_contents[$i][] = array('tr' => 'class="liste_total"', 'td' => 'align="left"', 'text' => $langs->trans("Total") . "&nbsp;" . $textHead);
     $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ') . "&nbsp;" . $langs->trans("Tasks"));
     $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot, 'all', 25200, 5));
     $this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot, 'all', 25200, 5));
     $this->info_box_contents[$i][] = array('td' => '', 'text' => "");
 }
Пример #8
0
	/**
	 *	\brief      Fonction generant la fiche d'intervention sur le disque
	 *	\param	    fichinter		Object fichinter
	 *	\param		outputlangs		Lang output object
	 *	\return	    int     		1=ok, 0=ko
	 */
	function write_file($fichinter,$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 (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';

		$outputlangs->load("main");
		$outputlangs->load("dict");
		$outputlangs->load("companies");
		$outputlangs->load("interventions");

		if ($conf->ficheinter->dir_output)
		{
			// If $fichinter is id instead of object
			if (! is_object($fichinter))
			{
				$id = $fichinter;
				$fichinter = new Fichinter($this->db);
				$result=$fichinter->fetch($id);
				if ($result < 0)
				{
					dol_print_error($this->db,$fichinter->error);
				}
			}

            $fichinter->fetch_thirdparty();

			$fichref = dol_sanitizeFileName($fichinter->ref);
			$dir = $conf->ficheinter->dir_output;
			if (! preg_match('/specimen/i',$fichref)) $dir.= "/" . $fichref;
			$file = $dir . "/" . $fichref . ".pdf";

			if (! file_exists($dir))
			{
				if (create_exdir($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));

				$pdf->Open();
				$pagenb=0;
				$pdf->SetDrawColor(128,128,128);

				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
				$pdf->SetAutoPageBreak(1,0);

				// New page
				$pdf->AddPage();
				$pagenb++;
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->MultiCell(0, 3, '');		// Set interline to 3

				// Pagehead

				//Affiche le filigrane brouillon - Print Draft Watermark
				if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
				{
                    pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
				}

				$posy=$this->marge_haute;

				$pdf->SetXY($this->marge_gauche,$posy);

				// Logo
				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
				if ($mysoc->logo)
				{
					if (is_readable($logo))
					{
						$pdf->Image($logo, $this->marge_gauche, $posy, 0, 24);
					}
					else
					{
						$pdf->SetTextColor(200,0,0);
						$pdf->SetFont('','B', $default_font_size - 2);
						$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
						$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
					}
				}

				// Nom emetteur
				$posy=40;
				$hautcadre=40;
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size - 2);

				$pdf->SetXY($this->marge_gauche,$posy);
				$pdf->SetFillColor(230,230,230);
				$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);


				$pdf->SetXY($this->marge_gauche+2,$posy+3);

				// Sender name
				$pdf->SetTextColor(0,0,60);
				$pdf->SetFont('','B', $default_font_size);
				$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');

				// Sender properties
				$carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);

				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->SetXY($this->marge_gauche+2,$posy+9);
				$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

				$object=$fichinter;

				// Recipient name
				if (! empty($usecontact))
				{
					// On peut utiliser le nom de la societe du contact
					if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
					else $socname = $object->client->nom;
					$carac_client_name=$outputlangs->convToOutputCharset($socname);
				}
				else
				{
					$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
				}

				$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');

				// Client destinataire
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','B', $default_font_size);
				$fichinter->fetch_thirdparty();
				$pdf->SetXY(102,42);
				$pdf->MultiCell(86,4, $carac_client_name, 0, 'L');
				$pdf->SetFont('','', $default_font_size - 1);
				$pdf->SetXY(102,$pdf->GetY());
				$pdf->MultiCell(66,4, $carac_client, 0, 'L');
				$pdf->rect(100, 40, 100, 40);


				$pdf->SetTextColor(0,0,100);
				$pdf->SetFont('','B', $default_font_size + 2);
				$pdf->SetXY(10,86);
				$pdf->MultiCell(120, 4, $outputlangs->transnoentities("InterventionCard")." : ".$outputlangs->convToOutputCharset($fichinter->ref), 0, 'L');

				$pdf->SetFillColor(220,220,220);
				$pdf->SetTextColor(0,0,0);
				$pdf->SetFont('','', $default_font_size);


				$tab_top = 100;
				$tab_top_newpage = 50;
				$tab_height = 110;
				$tab_height_newpage = 150;

				// Affiche notes
				if (! empty($fichinter->note_public))
				{
					$tab_top = 98;

					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
					$pdf->SetXY ($this->posxdesc-1, $tab_top);
					$pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fichinter->note_public), 0, 'L');
					$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;
				}

				$pdf->SetXY (10, $tab_top);
				$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
				$pdf->line(10, $tab_top + 8, 200, $tab_top + 8 );

				$pdf->SetFont('','', $default_font_size - 1);

				$pdf->MultiCell(0, 3, '');		// Set interline to 3
				$pdf->SetXY (10, $tab_top + 8 );
				$desc=dol_htmlentitiesbr($fichinter->description,1);
				//print $outputlangs->convToOutputCharset($desc); exit;
				$pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1);
				$nexY = $pdf->GetY();

				$pdf->line(10, $nexY, 200, $nexY);

				$pdf->MultiCell(0, 3, '');		// Set interline to 3. Then writeMultiCell must use 3 also.

				//dol_syslog("desc=".dol_htmlentitiesbr($fichinter->description));
				$nblignes = sizeof($fichinter->lines);

				$curY = $pdf->GetY();
				$nexY = $pdf->GetY();

				// Loop on each lines
				for ($i = 0 ; $i < $nblignes ; $i++)
				{
					$fichinterligne = $fichinter->lines[$i];

					$valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0;
					if ($valide>0)
					{
						$curY = $nexY+3;

						$pdf->SetXY (10, $curY);
						$pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY,
						dol_htmlentitiesbr($outputlangs->transnoentities("Date")." : ".dol_print_date($fichinterligne->datei,'dayhour',false,$outputlangs,true)." - ".$outputlangs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration),1,$outputlangs->charset_output), 0, 1, 0);
						$nexY = $pdf->GetY();

						$pdf->SetXY (10, $curY + 3);
						$desc = dol_htmlentitiesbr($fichinterligne->desc,1);
						$pdf->writeHTMLCell(0, 3, $this->marge_gauche, $curY + 3, $desc, 0, 1, 0);
						$nexY+=dol_nboflines_bis($fichinterligne->desc,52,$outputlangs->charset_output)*3;
					}
				}
				//$pdf->line(10, $tab_top+$tab_height+3, 200, $tab_top+$tab_height+3);

				// Rectangle for title and all lines
				$pdf->Rect(10, $tab_top, 190, $tab_height+3);
				$pdf->SetXY (10, $pdf->GetY() + 20);
				$pdf->MultiCell(60, 5, '', 0, 'J', 0);

				$pdf->SetXY(20,220);
				$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);

				$pdf->SetXY(20,225);
				$pdf->MultiCell(80,30, '', 1);

				$pdf->SetXY(110,220);
				$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);

				$pdf->SetXY(110,225);
				$pdf->MultiCell(80,30, '', 1);

				$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut

				$this->_pagefoot($pdf,$fichinter,$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
	}
Пример #9
0
		$companystatic->client=$objp->client;
		print $companystatic->getNomUrl(1,'',44);
		print '</td>';
        print '<td>'.dol_htmlentitiesbr(dol_trunc($objp->description,20)).'</td>';
		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 "</tr>\n";

		$total += $objp->duree;
		$i++;
	}
	print '<tr class="liste_total"><td colspan="5" class="liste_total">'.$langs->trans("Total").'</td>';
	print '<td align="right" nowrap="nowrap" class="liste_total">'.ConvertSecondToTime($total).'</td><td>&nbsp;</td>';
	print '</tr>';

	print '</table>';
	print "</form>\n";
	$db->free($result);
}
else
{
	dol_print_error($db);
}

$db->close();

llxFooter('$Date: 2011/07/31 23:50:54 $ - $Revision: 1.66 $');
?>
Пример #10
0
    /**
     */
    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;
    }