/**
  *  Load data for box to show them later
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 10)
 {
     global $user, $langs, $db, $conf;
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php';
     $ficheinterstatic = new Fichinter($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max));
     if ($user->rights->ficheinter->lire) {
         $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut,";
         $sql .= " f.datec,";
         $sql .= " f.date_valid as datev,";
         $sql .= " f.tms as datem,";
         $sql .= " s.nom, s.rowid as socid, s.client";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         if (!$user->rights->societe->client->voir) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= ", " . MAIN_DB_PREFIX . "fichinter as f";
         $sql .= " WHERE f.fk_soc = s.rowid ";
         $sql .= " AND f.entity = " . $conf->entity;
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id;
         }
         $sql .= " ORDER BY f.tms DESC";
         $sql .= $db->plimit($max, 0);
         dol_syslog(get_class($this) . '::loadBox sql=' . $sql, LOG_DEBUG);
         $resql = $db->query($sql);
         if ($resql) {
             $num = $db->num_rows($resql);
             $now = dol_now();
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($resql);
                 $datec = $db->jdate($objp->datec);
                 $ficheinterstatic->statut = $objp->fk_statut;
                 $ficheinterstatic->id = $objp->rowid;
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/fichinter/fiche.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref ? $objp->ref : $objp->rowid, 'url' => DOL_URL_ROOT . "/fichinter/fiche.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => dol_trunc($objp->nom, 40), 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datec, 'day'));
                 $this->info_box_contents[$i][5] = array('td' => 'align="right" class="nowrap"', 'text' => $ficheinterstatic->getLibStatut(6), 'asis' => 1);
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInterventions"));
             }
             $db->free($resql);
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     } else {
         $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
Exemple #2
0
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Fichinter($db);
$object->fetch($id, $ref);
$upload_dir = $conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($object->ref);
$modulepart = 'fichinter';
/*
 * Actions
 */
if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
    require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
    if (dol_mkdir($upload_dir) >= 0) {
        $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']);
        if (is_numeric($resupload) && $resupload > 0) {
            if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) {
                // Create small thumbs for company (Ratio is near 16/9)
                // Used on logon for example
                $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
Exemple #3
0
$search_ref = GETPOST('search_ref') ? GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
$search_company = GETPOST('search_company', 'alpha');
$search_desc = GETPOST('search_desc', 'alpha');
$search_status = GETPOST('search_status');
$sall = GETPOST('sall');
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) {
    $search_ref = "";
    $search_company = "";
    $search_desc = "";
    $search_status = "";
}
/*
 *	View
 */
$form = new Form($db);
$interventionstatic = new Fichinter($db);
llxHeader('', $langs->trans("Intervention"));
$sql = "SELECT";
$sql .= " f.ref, f.rowid as fichid, f.fk_statut, f.description,";
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
    $sql .= " fd.description as descriptiondetail, fd.date as dp, fd.duree,";
}
$sql .= " s.nom as name, s.rowid as socid, s.client";
$sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s";
if (!$user->rights->societe->client->voir && empty($socid)) {
    $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
}
$sql .= ", " . MAIN_DB_PREFIX . "fichinter as f)";
if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "fichinterdet as fd ON fd.fk_fichinter = f.rowid";
}
function _header($id, $object_type)
{
    global $db, $langs;
    $langs->load('interventions');
    $langs->load('contracts');
    if ($object_type == 'contrat') {
        $object = new Contrat($db);
        $object->fetch($id);
        dol_include_once('/core/lib/contract.lib.php');
        $head = contract_prepare_head($object);
        dol_fiche_head($head, 'dispatchAsset', $langs->trans("Contract"), 0, 'contract');
    } else {
        if ($object_type == 'intervention') {
            $object = new Fichinter($db);
            $object->fetch($id);
            dol_include_once('/core/lib/fichinter.lib.php');
            $head = fichinter_prepare_head($object);
            dol_fiche_head($head, 'dispatchAsset', $langs->trans("InterventionCard"), 0, 'intervention');
        } else {
            if ($object_type == 'ticketsup') {
                dol_include_once('/ticketsup/class/ticketsup.class.php');
                dol_include_once('/ticketsup/lib/ticketsup.lib.php');
                $object = new Ticketsup($db);
                $object->fetch($id);
                $head = ticketsup_prepare_head($object);
                dol_fiche_head($head, 'dispatchAsset', $langs->trans("Ticket"), 0, 'ticketsup@ticketsup');
            }
        }
    }
    return $object;
}
Exemple #5
0
$originid = GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int');
// For backward compatibility
$note_public = GETPOST('note_public');
$lineid = GETPOST('line_id', 'int');
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('interventioncard', 'globalcard'));
$object = new Fichinter($db);
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
    if ($ret > 0) {
        $ret = $object->fetch_thirdparty();
    }
    if ($ret < 0) {
        dol_print_error('', $object->error);
    }
}
$permissionnote = $user->rights->ficheinter->creer;
// Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->ficheinter->creer;
Exemple #6
0
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fichinter.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
$langs->load("interventions");
$langs->load("sendings");
$langs->load("companies");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$result = $object->fetch($id, $ref);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int');
        $result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha'));
    }
    if ($result >= 0) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
        exit;
    } else {
        if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            $langs->load("errors");
Exemple #7
0
 *	\brief      Fiche d'information sur une fiche d'intervention
 */
require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT . "/fichinter/class/fichinter.class.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/fichinter.lib.php";
$langs->load('companies');
$langs->load("interventions");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$object->fetch($id, $ref);
/*
 * Actions
 */
if ($action == 'setnote_public' && $user->rights->ficheinter->creer) {
    $result = $object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
    if ($result < 0) {
        dol_print_error($db, $object->error);
    }
} else {
    if ($action == 'setnote_private' && $user->rights->ficheinter->creer) {
        $result = $object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES));
        if ($result < 0) {
            dol_print_error($db, $object->error);
        }
Exemple #8
0
    if ($_GET["socid"] > 0)
    {
        $societe->fetch($_GET["socid"]);
    }

    print_fiche_titre($langs->trans("AddIntervention"));

    dol_htmloutput_mesg($mesg);

    if (! $conf->global->FICHEINTER_ADDON)
    {
        dol_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
        exit;
    }

    $ficheinter = new Fichinter($db);
    $ficheinter->date = time();
    if ($fichinterid) $result=$ficheinter->fetch($fichinterid);

    $obj = $conf->global->FICHEINTER_ADDON;
    $obj = "mod_".$obj;

    $modFicheinter = new $obj;
    $numpr = $modFicheinter->getNextValue($societe,$ficheinter);

    if ($_GET["socid"] > 0)
    {
        print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';

        print '<table class="border" width="100%">';
Exemple #9
0
         }
     } else {
         dol_print_error($db);
     }
 }
 /*
  * Last interventions
  */
 if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
     $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "fichinter as f";
     $sql .= " WHERE f.fk_soc = s.rowid";
     $sql .= " AND s.rowid = " . $object->id;
     $sql .= " AND f.entity = " . $conf->entity;
     $sql .= " ORDER BY f.tms DESC";
     $fichinter_static = new Fichinter($db);
     $resql = $db->query($sql);
     if ($resql) {
         $var = true;
         $num = $db->num_rows($resql);
         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;
Exemple #10
0
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php';
if (!$user->rights->ficheinter->lire) {
    accessforbidden();
}
$langs->load("interventions");
// Security check
$socid = GETPOST('socid', 'int');
if ($user->societe_id > 0) {
    $action = '';
    $socid = $user->societe_id;
}
/*
 * View
 */
$fichinterstatic = new Fichinter($db);
$form = new Form($db);
$formfile = new FormFile($db);
$help_url = "EN:ModuleFichinters|FR:Module_Fiche_Interventions|ES:Módulo_FichaInterventiones";
llxHeader("", $langs->trans("Interventions"), $help_url);
print load_fiche_titre($langs->trans("InterventionsArea"));
//print '<table width="100%" class="notopnoleftnoright">';
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
print '<div class="fichecenter"><div class="fichethirdleft">';
// Search ficheinter
$var = false;
print '<table class="noborder nohover" width="100%">';
print '<form method="post" action="' . DOL_URL_ROOT . '/fichinter/list.php">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("Search") . '</td></tr>';
print '<tr ' . $bc[$var] . '><td>';
Exemple #11
0
    /**
     * testFichinterBuild
     *
     * @return int
     */
    public function testFichinterBuild()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

        $conf->fichinter->dir_output.='/temp';
        $localobject=new Fichinter($this->savdb);
        $localobject->initAsSpecimen();

        // Soleil
        $localobject->modelpdf='soleil';
        $result=fichinter_create($db, $localobject, $localobject->modelpdf, $langs);

        $this->assertLessThan($result, 0);
        print __METHOD__." result=".$result."\n";

        return 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
	}
Exemple #13
0
}
if ($action == 'other') {
	$value = GETPOST('activate_mergePropalProductCard','alpha');
	$res = dolibarr_set_const($db, "PRODUIT_PDF_MERGE_PROPAL", $value,'chaine',0,'',$conf->entity);
}
if ($action == 'other')
{
	$value = GETPOST('activate_usesearchtoselectproduct','alpha');
	$res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $value,'chaine',0,'',$conf->entity);
}

if ($action == 'specimen') // For products
{
	$modele= GETPOST('module','alpha');

	$inter = new Fichinter($db);
	$inter->initAsSpecimen();

	// Search template files
	$file=''; $classname=''; $filefound=0;
	$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
	foreach($dirmodels as $reldir)
	{
	    $file=dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php",0);
		if (file_exists($file))
		{
			$filefound=1;
			$classname = "pdf_".$modele;
			break;
		}
	}
Exemple #14
0
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Fichinter($db);
$object->fetch($id, $ref);
$upload_dir = $conf->ficheinter->dir_output . '/' . dol_sanitizeFileName($object->ref);
$modulepart = 'fichinter';
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
$form = new Form($db);
llxHeader('', $langs->trans("Intervention"));
if ($object->id) {
    $object->fetch_thirdparty();
    $head = fichinter_prepare_head($object);
/**
 * 	Deletes the image preview, in case of regeneration
 * 	@param	  db			database object
 * 	@param	  fichinterid	id to delete
 * 	@param    fichinterref	reference if needed
 */
function fichinter_delete_preview($db, $fichinterid, $fichinterref='')
{
	global $langs,$conf;
    require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");

	if (!$fichinterref)
	{
		$fichinter = new Fichinter($db);
		$fichinter->fetch($fichinterid);
		$fichinterref = $fichinter->ref;
	}

	if ($conf->ficheinter->dir_output)
	{
		$fichinterref = dol_sanitizeFileName($fichinterref);
		$dir = $conf->ficheinter->dir_output . "/" . $fichinterref ;
		$file = $dir . "/" . $fichinterref . ".pdf.png";
		$multiple = $file . ".";

		if ( file_exists( $file ) && is_writable( $file ) )
		{
			if ( ! dol_delete_file($file,1) )
			{
				$this->error=$langs->trans("ErrorFailedToOpenFile",$file);
				return 0;
			}
		}
		else
		{
			for ($i = 0; $i < 20; $i++)
			{
				$preview = $multiple.$i;
				if ( file_exists( $preview ) && is_writable( $preview ) )
				{
					if ( ! dol_delete_file($preview,1) )
					{
						$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
						return 0;
					}
				}
			}
		}
	}

	return 1;
}
Exemple #16
0
$socid = 0;
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
llxHeader();
$form = new Form($db);
/* *************************************************************************** */
/*                                                                             */
/* Mode fiche                                                                  */
/*                                                                             */
/* *************************************************************************** */
if ($id > 0 || !empty($ref)) {
    $object = new Fichinter($db);
    if ($object->fetch($id, $ref) > 0) {
        $soc = new Societe($db);
        $soc->fetch($object->socid);
        $head = fichinter_prepare_head($object);
        dol_fiche_head($head, 'preview', $langs->trans("InterventionCard"), 0, 'intervention');
        /*
         *   Fiche intervention
         */
        print '<table class="border" width="100%">';
        // Ref
        print '<tr><td width="18%">' . $langs->trans("Ref") . "</td>";
        print '<td colspan="2">' . $object->ref . '</td>';
        $nbrow = 4;
        print '<td rowspan="' . $nbrow . '" valign="top" width="50%">';
        /*
Exemple #17
0
 /**
  * testFichinterDelete
  *
  * @param	int		$id		Id of intervention
  * @return	int
  *
  * @depends	testFichinterOther
  * The depends says test is run only if previous is ok
  */
 public function testFichinterDelete($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Fichinter($this->savdb);
     $result = $localobject->fetch($id);
     $result = $localobject->delete($user);
     print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }
Exemple #18
0
$formcompany = new FormCompany($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);


/* *************************************************************************** */
/*                                                                             */
/* Mode vue et edition                                                         */
/*                                                                             */
/* *************************************************************************** */
if (isset($mesg)) print $mesg;

$id = $_GET["id"];
if ($id > 0)
{
	$fichinter = New Fichinter($db);
	if ($fichinter->fetch($_GET['id']) > 0)
	{
		$soc = new Societe($db, $fichinter->socid);
		$soc->fetch($fichinter->socid);


		$head = fichinter_prepare_head($fichinter);
		dol_fiche_head($head, 'contact', $langs->trans("InterventionCard"), 0, 'intervention');


		/*
		*   Fiche intervention synthese pour rappel
		*/
		print '<table class="border" width="100%">';
Exemple #19
0
         }
     } else {
         dol_print_error($db);
     }
 }
 /*
  * Last interventions
  */
 if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
     $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "fichinter as f";
     $sql .= " WHERE f.fk_soc = s.rowid";
     $sql .= " AND s.rowid = " . $object->id;
     $sql .= " AND f.entity = " . $conf->entity;
     $sql .= " ORDER BY f.tms DESC";
     $fichinter_static = new Fichinter($db);
     $resql = $db->query($sql);
     if ($resql) {
         $var = true;
         $num = $db->num_rows($resql);
         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;
Exemple #20
0
 *	\ingroup    fichinter
 *	\brief      Page d'affichage des infos d'une fiche d'intervention
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/fichinter.lib.php';
$langs->load('companies');
$langs->load("interventions");
$id = GETPOST('id', 'int');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
if ($id > 0) {
    $object->fetch($id);
}
/*
 *	View
 */
llxHeader('', $langs->trans("Intervention"));
$societe = new Societe($db);
$societe->fetch($object->socid);
$head = fichinter_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention');
$object->info($object->id);
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
Exemple #21
0
$langs->load("interventions");

$fichinterid = GETPOST("id");

// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');


/*
*	View
*/

llxHeader();

$fichinter = new Fichinter($db);
$fichinter->fetch($fichinterid);

$societe = new Societe($db);
$societe->fetch($fichinter->socid);

$head = fichinter_prepare_head($fichinter);
dol_fiche_head($head, 'info', $langs->trans('InterventionCard'), 0, 'intervention');

$fichinter->info($fichinter->id);

print '<table width="100%"><tr><td>';
dol_print_object_info($fichinter);
print '</td></tr></table>';

print '</div>';
Exemple #22
0
 if (preg_match('/^Error/', $tmp)) {
     print '<div class="error">' . $langs->trans($tmp) . '</div>';
 } elseif ($tmp == 'NotConfigured') {
     print $langs->trans($tmp);
 } else {
     print $tmp;
 }
 print '</td>' . "\n";
 print '<td align="center">';
 if ($conf->global->FICHEINTER_ADDON == $classname) {
     print img_picto($langs->trans("Activated"), 'switch_on');
 } else {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=' . $classname . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
 }
 print '</td>';
 $ficheinter = new Fichinter($db);
 $ficheinter->initAsSpecimen();
 // Info
 $htmltooltip = '';
 $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
 $nextval = $module->getNextValue($mysoc, $ficheinter);
 if ("{$nextval}" != $langs->trans("NotAvailable")) {
     // Keep " on nextval
     $htmltooltip .= '' . $langs->trans("NextValue") . ': ';
     if ($nextval) {
         if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
             $nextval = $langs->trans($nextval);
         }
         $htmltooltip .= $nextval . '<br>';
     } else {
         $htmltooltip .= $langs->trans($module->error) . '<br>';
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int');
// For backward compatibility
$note_public = GETPOST('note_public');
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('interventioncard'));
$object = new Fichinter($db);
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
    if ($ret > 0) {
        $ret = $object->fetch_thirdparty();
    }
    if ($ret < 0) {
        dol_print_error('', $object->error);
    }
}
$permissionnote = $user->rights->ficheinter->creer;
// Used by the include of actions_setnotes.inc.php
/*
Exemple #24
0
     } else {
         dol_print_error($db);
     }
     print "</table>";
 }
 /*
  * Last interventions
  */
 if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
     print '<table class="noborder" width="100%">';
     $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "fichinter as f";
     $sql .= " WHERE f.fk_soc = s.rowid";
     $sql .= " AND s.rowid = " . $objsoc->id;
     $sql .= " ORDER BY f.tms DESC";
     $fichinter_static = new Fichinter($db);
     $resql = $db->query($sql);
     if ($resql) {
         $var = true;
         $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;
Exemple #25
0
$result = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');


// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";


$object = new Fichinter($db);
$object->fetch($fichinterid);

$upload_dir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart='fichinter';


/*
 * Action envoie fichier
 */
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
	require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");

	if (create_exdir($upload_dir) >= 0)
	{