예제 #1
0
 /**
  *  Load data into info_box_contents array to show array later.
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $user, $langs, $db, $conf;
     $langs->load("boxes");
     $this->max = $max;
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
     if ($user->rights->societe->lire) {
         $sql = "SELECT sp.rowid, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc,";
         $sql .= " s.nom as socname";
         $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as sp";
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON sp.fk_soc = s.rowid";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE sp.entity IN (" . getEntity('societe', 1) . ")";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = "******" AND sp.fk_soc = {$user->societe_id}";
         }
         $sql .= " ORDER BY sp.tms DESC";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $contactstatic = new Contact($db);
             $societestatic = new Societe($db);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $datec = $db->jdate($objp->datec);
                 $datem = $db->jdate($objp->tms);
                 $contactstatic->lastname = $objp->lastname;
                 $contactstatic->firstname = $objp->firstname;
                 $contactstatic->civility_id = $objp->civility_id;
                 $societestatic->id = $objp->fk_soc;
                 $societestatic->name = $objp->socname;
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/contact/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $contactstatic->getFullName($langs, 0), 'url' => DOL_URL_ROOT . "/contact/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => $objp->fk_soc > 0 ? 'company' : '', 'url' => $objp->fk_soc > 0 ? DOL_URL_ROOT . "/societe/soc.php?socid=" . $objp->fk_soc : '');
                 $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => $societestatic->name, 'url' => DOL_URL_ROOT . "/societe/soc.php?socid=" . $objp->fk_soc);
                 $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datem, "day"));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedContacts"));
             }
             $db->free($result);
         } 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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
예제 #2
0
/**
 *   	Return a string with full address formated
 *
 * 		@param	Translate	$outputlangs		Output langs object
 *   	@param  Societe		$sourcecompany		Source company object
 *   	@param  Societe		$targetcompany		Target company object
 *      @param  Contact		$targetcontact		Target contact object
 * 		@param	int			$usecontact			Use contact instead of company
 * 		@param	int			$mode				Address type ('source', 'target', 'targetwithdetails')
 * 		@return	string							String with full address
 */
function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $targetcontact = '', $usecontact = 0, $mode = 'source')
{
    global $conf;
    $stringaddress = '';
    if ($mode == 'source' && !is_object($sourcecompany)) {
        return -1;
    }
    if ($mode == 'target' && !is_object($targetcompany)) {
        return -1;
    }
    if (!empty($sourcecompany->state_id) && empty($sourcecompany->departement)) {
        $sourcecompany->departement = getState($sourcecompany->state_id);
    }
    //TODO: Deprecated
    if (!empty($sourcecompany->state_id) && empty($sourcecompany->state)) {
        $sourcecompany->state = getState($sourcecompany->state_id);
    }
    if (!empty($targetcompany->state_id) && empty($targetcompany->departement)) {
        $targetcompany->departement = getState($targetcompany->state_id);
    }
    if ($mode == 'source') {
        $withCountry = 0;
        if (!empty($sourcecompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
            $withCountry = 1;
        }
        $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs)) . "\n";
        if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) {
            // Phone
            if ($sourcecompany->phone) {
                $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("PhoneShort") . ": " . $outputlangs->convToOutputCharset($sourcecompany->phone);
            }
            // Fax
            if ($sourcecompany->fax) {
                $stringaddress .= ($stringaddress ? $sourcecompany->phone ? " - " : "\n" : '') . $outputlangs->transnoentities("Fax") . ": " . $outputlangs->convToOutputCharset($sourcecompany->fax);
            }
            // EMail
            if ($sourcecompany->email) {
                $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Email") . ": " . $outputlangs->convToOutputCharset($sourcecompany->email);
            }
            // Web
            if ($sourcecompany->url) {
                $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Web") . ": " . $outputlangs->convToOutputCharset($sourcecompany->url);
            }
        }
    }
    if ($mode == 'target' || $mode == 'targetwithdetails') {
        if ($usecontact) {
            $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->convToOutputCharset($targetcontact->getFullName($outputlangs, 1));
            if (!empty($targetcontact->address)) {
                $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->convToOutputCharset(dol_format_address($targetcontact)) . "\n";
            } else {
                $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->convToOutputCharset(dol_format_address($targetcompany)) . "\n";
            }
            // Country
            if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) {
                $stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $targetcontact->country_code)) . "\n";
            } else {
                if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
                    $stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $targetcompany->country_code)) . "\n";
                }
            }
            if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') {
                // Phone
                if (!empty($targetcontact->phone_pro) || !empty($targetcontact->phone_mobile)) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Phone") . ": ";
                }
                if (!empty($targetcontact->phone_pro)) {
                    $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro);
                }
                if (!empty($targetcontact->phone_pro) && !empty($targetcontact->phone_mobile)) {
                    $stringaddress .= " / ";
                }
                if (!empty($targetcontact->phone_mobile)) {
                    $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile);
                }
                // Fax
                if ($targetcontact->fax) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Fax") . ": " . $outputlangs->convToOutputCharset($targetcontact->fax);
                }
                // EMail
                if ($targetcontact->email) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Email") . ": " . $outputlangs->convToOutputCharset($targetcontact->email);
                }
                // Web
                if ($targetcontact->url) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Web") . ": " . $outputlangs->convToOutputCharset($targetcontact->url);
                }
            }
        } else {
            $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->convToOutputCharset(dol_format_address($targetcompany)) . "\n";
            // Country
            if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) {
                $stringaddress .= $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $targetcompany->country_code)) . "\n";
            }
            if (!empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails') {
                // Phone
                if (!empty($targetcompany->phone) || !empty($targetcompany->phone_mobile)) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Phone") . ": ";
                }
                if (!empty($targetcompany->phone)) {
                    $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone);
                }
                if (!empty($targetcompany->phone) && !empty($targetcompany->phone_mobile)) {
                    $stringaddress .= " / ";
                }
                if (!empty($targetcompany->phone_mobile)) {
                    $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile);
                }
                // Fax
                if ($targetcompany->fax) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Fax") . ": " . $outputlangs->convToOutputCharset($targetcompany->fax);
                }
                // EMail
                if ($targetcompany->email) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Email") . ": " . $outputlangs->convToOutputCharset($targetcompany->email);
                }
                // Web
                if ($targetcompany->url) {
                    $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("Web") . ": " . $outputlangs->convToOutputCharset($targetcompany->url);
                }
            }
        }
        // Intra VAT
        if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) {
            if ($targetcompany->tva_intra) {
                $stringaddress .= "\n" . $outputlangs->transnoentities("VATIntraShort") . ': ' . $outputlangs->convToOutputCharset($targetcompany->tva_intra);
            }
        }
        // Professionnal Ids
        if (!empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && !empty($targetcompany->idprof1)) {
            $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code);
            if (preg_match('/\\((.+)\\)/', $tmp, $reg)) {
                $tmp = $reg[1];
            }
            $stringaddress .= "\n" . $tmp . ': ' . $outputlangs->convToOutputCharset($targetcompany->idprof1);
        }
        if (!empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && !empty($targetcompany->idprof2)) {
            $tmp = $outputlangs->transcountrynoentities("ProfId2", $targetcompany->country_code);
            if (preg_match('/\\((.+)\\)/', $tmp, $reg)) {
                $tmp = $reg[1];
            }
            $stringaddress .= "\n" . $tmp . ': ' . $outputlangs->convToOutputCharset($targetcompany->idprof2);
        }
        if (!empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && !empty($targetcompany->idprof3)) {
            $tmp = $outputlangs->transcountrynoentities("ProfId3", $targetcompany->country_code);
            if (preg_match('/\\((.+)\\)/', $tmp, $reg)) {
                $tmp = $reg[1];
            }
            $stringaddress .= "\n" . $tmp . ': ' . $outputlangs->convToOutputCharset($targetcompany->idprof3);
        }
        if (!empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && !empty($targetcompany->idprof4)) {
            $tmp = $outputlangs->transcountrynoentities("ProfId4", $targetcompany->country_code);
            if (preg_match('/\\((.+)\\)/', $tmp, $reg)) {
                $tmp = $reg[1];
            }
            $stringaddress .= "\n" . $tmp . ': ' . $outputlangs->convToOutputCharset($targetcompany->idprof4);
        }
    }
    return $stringaddress;
}
예제 #3
0
파일: fiche.php 프로젝트: netors/dolibarr
         print preg_replace('/./i', '*', $fuser->phenix_pass_crypted);
     }
     print '</td></tr>';
 }
 // Company / Contact
 if ($conf->societe->enabled) {
     print '<tr><td width="25%" valign="top">' . $langs->trans("LinkToCompanyContact") . '</td>';
     print '<td>';
     if ($fuser->societe_id > 0) {
         $societe = new Societe($db);
         $societe->fetch($fuser->societe_id);
         print $societe->getNomUrl(1, '');
         if ($fuser->contact_id) {
             $contact = new Contact($db);
             $contact->fetch($fuser->contact_id);
             print ' / <a href="' . DOL_URL_ROOT . '/contact/fiche.php?id=' . $fuser->contact_id . '">' . img_object($langs->trans("ShowContact"), 'contact') . ' ' . dol_trunc($contact->getFullName($langs), 32) . '</a>';
         }
     } else {
         print $langs->trans("ThisUserIsNot");
     }
     print '</td>';
     print "</tr>\n";
 }
 // Module Adherent
 if ($conf->adherent->enabled) {
     $langs->load("members");
     print '<tr><td width="25%" valign="top">' . $langs->trans("LinkedToDolibarrMember") . '</td>';
     print '<td>';
     if ($fuser->fk_member) {
         $adh = new Adherent($db);
         $adh->fetch($fuser->fk_member);
 /**
  *	Function to build a document on disk using the generic odt module.
  *
  *	@param	Project		$object					Object source to build document
  *	@param	Translate	$outputlangs			Lang output object
  * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
  *	@return	int         						1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs, $srctemplatepath)
 {
     global $user, $langs, $conf, $mysoc, $hookmanager;
     if (empty($srctemplatepath)) {
         dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
         return -1;
     }
     // Add odtgeneration hook
     if (!is_object($hookmanager)) {
         include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
         $hookmanager = new HookManager($this->db);
     }
     $hookmanager->initHooks(array('odtgeneration'));
     global $action;
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     $sav_charset_output = $outputlangs->charset_output;
     $outputlangs->charset_output = 'UTF-8';
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("projects");
     if ($conf->projet->dir_output) {
         // If $object is id instead of object
         if (!is_object($object)) {
             $id = $object;
             $object = new Project($this->db);
             $result = $object->fetch($id);
             if ($result < 0) {
                 dol_print_error($this->db, $object->error);
                 return -1;
             }
         }
         $dir = $conf->projet->dir_output;
         $objectref = dol_sanitizeFileName($object->ref);
         if (!preg_match('/specimen/i', $objectref)) {
             $dir .= "/" . $objectref;
         }
         $file = $dir . "/" . $objectref . ".odt";
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return -1;
             }
         }
         if (file_exists($dir)) {
             //print "srctemplatepath=".$srctemplatepath;	// Src filename
             $newfile = basename($srctemplatepath);
             $newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile);
             $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
             $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
             $newfiletmp = $objectref . '_' . $newfiletmp;
             //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
             // Get extension (ods or odt)
             $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
             if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
                 $filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
             } else {
                 $filename = $newfiletmp . '.' . $newfileformat;
             }
             $file = $dir . '/' . $filename;
             //print "newdir=".$dir;
             //print "newfile=".$newfile;
             //print "file=".$file;
             //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
             dol_mkdir($conf->projet->dir_temp);
             $socobject = $object->thirdparty;
             // Make substitution
             $substitutionarray = array('__FROM_NAME__' => $this->emetteur->nom, '__FROM_EMAIL__' => $this->emetteur->email);
             complete_substitutions_array($substitutionarray, $langs, $object);
             // Open and load template
             require_once ODTPHP_PATH . 'odf.php';
             try {
                 $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->projet->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
             } catch (Exception $e) {
                 $this->error = $e->getMessage();
                 return -1;
             }
             // After construction $odfHandler->contentXml contains content and
             // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
             // [!-- BEGIN lines --]*[!-- END lines --]
             //print html_entity_decode($odfHandler->__toString());
             //print exit;
             // Make substitutions into odt of user info
             $tmparray = $this->get_substitutionarray_user($user, $outputlangs);
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         //var_dump($value);exit;
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Make substitutions into odt of mysoc
             $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
             //var_dump($tmparray); exit;
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         //var_dump($value);exit;
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Make substitutions into odt of thirdparty
             $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Replace tags of object + external modules
             $tmparray = $this->get_substitutionarray_object($object, $outputlangs);
             complete_substitutions_array($tmparray, $outputlangs, $object);
             // Call the ODTSubstitution hook
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
             $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Replace tags of lines for tasks
             try {
                 $listlines = $odfHandler->setSegment('tasks');
                 $taskstatic = new Task($this->db);
                 // Security check
                 $socid = 0;
                 if (!empty($object->fk_soc)) {
                     $socid = $object->fk_soc;
                 }
                 $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
                 foreach ($tasksarray as $task) {
                     $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
                     //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
                     foreach ($tmparray as $key => $val) {
                         try {
                             $listlines->setVars($key, $val, true, 'UTF-8');
                         } catch (OdfException $e) {
                         } catch (SegmentException $e) {
                         }
                     }
                     $taskobj = new Task($this->db);
                     $taskobj->fetch($task->id);
                     // Replace tags of lines for contacts task
                     $sourcearray = array('internal', 'external');
                     $contact_arrray = array();
                     foreach ($sourcearray as $source) {
                         $contact_temp = $taskobj->liste_contact(-1, $source);
                         if (is_array($contact_temp) && count($contact_temp) > 0) {
                             $contact_arrray = array_merge($contact_arrray, $contact_temp);
                         }
                     }
                     if (is_array($contact_arrray) && count($contact_arrray) > 0) {
                         $listlinestaskres = $listlines->__get('tasksressources');
                         foreach ($contact_arrray as $contact) {
                             if ($contact['source'] == 'internal') {
                                 $objectdetail = new User($this->db);
                                 $objectdetail->fetch($contact['id']);
                                 $contact['socname'] = $mysoc->name;
                             } elseif ($contact['source'] == 'external') {
                                 $objectdetail = new Contact($this->db);
                                 $objectdetail->fetch($contact['id']);
                                 $soc = new Societe($this->db);
                                 $soc->fetch($contact['socid']);
                                 $contact['socname'] = $soc->name;
                             }
                             $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
                             $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
                             foreach ($tmparray as $key => $val) {
                                 try {
                                     $listlinestaskres->setVars($key, $val, true, 'UTF-8');
                                 } catch (OdfException $e) {
                                 } catch (SegmentException $e) {
                                 }
                             }
                             $listlinestaskres->merge();
                         }
                     }
                     //Time ressources
                     $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
                     $sql .= ", u.lastname, u.firstname";
                     $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task_time as t";
                     $sql .= " , " . MAIN_DB_PREFIX . "user as u";
                     $sql .= " WHERE t.fk_task =" . $task->id;
                     $sql .= " AND t.fk_user = u.rowid";
                     $sql .= " ORDER BY t.task_date DESC";
                     $resql = $this->db->query($sql);
                     if ($resql) {
                         $num = $this->db->num_rows($resql);
                         $i = 0;
                         $tasks = array();
                         $listlinestasktime = $listlines->__get('taskstimes');
                         while ($i < $num) {
                             $row = $this->db->fetch_array($resql);
                             if (!empty($row['fk_user'])) {
                                 $objectdetail = new User($this->db);
                                 $objectdetail->fetch($row['fk_user']);
                                 $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
                             } else {
                                 $row['fullcivname'] = '';
                             }
                             $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
                             foreach ($tmparray as $key => $val) {
                                 try {
                                     $listlinestasktime->setVars($key, $val, true, 'UTF-8');
                                 } catch (OdfException $e) {
                                 } catch (SegmentException $e) {
                                 }
                             }
                             $listlinestasktime->merge();
                             $i++;
                         }
                         $this->db->free($resql);
                     }
                     // Replace tags of project files
                     $listtasksfiles = $listlines->__get('tasksfiles');
                     $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref) . '/' . dol_sanitizeFileName($task->ref);
                     $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1);
                     foreach ($filearray as $filedetail) {
                         $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
                         //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
                         foreach ($tmparray as $key => $val) {
                             try {
                                 $listtasksfiles->setVars($key, $val, true, 'UTF-8');
                             } catch (OdfException $e) {
                             } catch (SegmentException $e) {
                             }
                         }
                         $listtasksfiles->merge();
                     }
                     $listlines->merge();
                 }
                 $odfHandler->mergeSegment($listlines);
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace tags of project files
             try {
                 $listlines = $odfHandler->setSegment('projectfiles');
                 $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref);
                 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1);
                 foreach ($filearray as $filedetail) {
                     //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
                     $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
                     foreach ($tmparray as $key => $val) {
                         try {
                             $listlines->setVars($key, $val, true, 'UTF-8');
                         } catch (OdfException $e) {
                         } catch (SegmentException $e) {
                         }
                     }
                     $listlines->merge();
                 }
                 $odfHandler->mergeSegment($listlines);
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace tags of lines for contacts
             $sourcearray = array('internal', 'external');
             $contact_arrray = array();
             foreach ($sourcearray as $source) {
                 $contact_temp = $object->liste_contact(-1, $source);
                 if (is_array($contact_temp) && count($contact_temp) > 0) {
                     $contact_arrray = array_merge($contact_arrray, $contact_temp);
                 }
             }
             if (is_array($contact_arrray) && count($contact_arrray) > 0) {
                 try {
                     $listlines = $odfHandler->setSegment('projectcontacts');
                     foreach ($contact_arrray as $contact) {
                         if ($contact['source'] == 'internal') {
                             $objectdetail = new User($this->db);
                             $objectdetail->fetch($contact['id']);
                             $contact['socname'] = $mysoc->name;
                         } elseif ($contact['source'] == 'external') {
                             $objectdetail = new Contact($this->db);
                             $objectdetail->fetch($contact['id']);
                             $soc = new Societe($this->db);
                             $soc->fetch($contact['socid']);
                             $contact['socname'] = $soc->name;
                         }
                         $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
                         $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
                         foreach ($tmparray as $key => $val) {
                             try {
                                 $listlines->setVars($key, $val, true, 'UTF-8');
                             } catch (OdfException $e) {
                             } catch (SegmentException $e) {
                             }
                         }
                         $listlines->merge();
                     }
                     $odfHandler->mergeSegment($listlines);
                 } catch (OdfException $e) {
                     $this->error = $e->getMessage();
                     dol_syslog($this->error, LOG_WARNING);
                     return -1;
                 }
             }
             //List of referent
             $listofreferent = array('propal' => array('title' => "ListProposalsAssociatedProject", 'class' => 'Propal', 'table' => 'propal', 'test' => $conf->propal->enabled && $user->rights->propale->lire), 'order' => array('title' => "ListOrdersAssociatedProject", 'class' => 'Commande', 'table' => 'commande', 'test' => $conf->commande->enabled && $user->rights->commande->lire), 'invoice' => array('title' => "ListInvoicesAssociatedProject", 'class' => 'Facture', 'table' => 'facture', 'test' => $conf->facture->enabled && $user->rights->facture->lire), 'invoice_predefined' => array('title' => "ListPredefinedInvoicesAssociatedProject", 'class' => 'FactureRec', 'table' => 'facture_rec', 'test' => $conf->facture->enabled && $user->rights->facture->lire), 'order_supplier' => array('title' => "ListSupplierOrdersAssociatedProject", 'table' => 'commande_fournisseur', 'class' => 'CommandeFournisseur', 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), 'invoice_supplier' => array('title' => "ListSupplierInvoicesAssociatedProject", 'table' => 'facture_fourn', 'class' => 'FactureFournisseur', 'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), 'contract' => array('title' => "ListContractAssociatedProject", 'class' => 'Contrat', 'table' => 'contrat', 'test' => $conf->contrat->enabled && $user->rights->contrat->lire), 'intervention' => array('title' => "ListFichinterAssociatedProject", 'class' => 'Fichinter', 'table' => 'fichinter', 'disableamount' => 1, 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire), 'trip' => array('title' => "ListTripAssociatedProject", 'class' => 'Deplacement', 'table' => 'deplacement', 'disableamount' => 1, 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire), 'agenda' => array('title' => "ListActionsAssociatedProject", 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire));
             //Insert reference
             try {
                 $listlines = $odfHandler->setSegment('projectrefs');
                 foreach ($listofreferent as $keyref => $valueref) {
                     $title = $valueref['title'];
                     $tablename = $valueref['table'];
                     $classname = $valueref['class'];
                     $qualified = $valueref['test'];
                     if ($qualified) {
                         $elementarray = $object->get_element_list($keyref, $tablename);
                         if (count($elementarray) > 0 && is_array($elementarray)) {
                             $var = true;
                             $total_ht = 0;
                             $total_ttc = 0;
                             $num = count($elementarray);
                             for ($i = 0; $i < $num; $i++) {
                                 $ref_array = array();
                                 $ref_array['type'] = $langs->trans($classname);
                                 $element = new $classname($this->db);
                                 $element->fetch($elementarray[$i]);
                                 $element->fetch_thirdparty();
                                 //Ref object
                                 $ref_array['ref'] = $element->ref;
                                 //Date object
                                 $dateref = $element->date;
                                 if (empty($dateref)) {
                                     $dateref = $element->datep;
                                 }
                                 if (empty($dateref)) {
                                     $dateref = $element->date_contrat;
                                 }
                                 $ref_array['date'] = $dateref;
                                 //Soc object
                                 if (is_object($element->thirdparty)) {
                                     $ref_array['socname'] = $element->thirdparty->name;
                                 } else {
                                     $ref_array['socname'] = '';
                                 }
                                 //Amount object
                                 if (empty($valueref['disableamount'])) {
                                     if (!empty($element->total_ht)) {
                                         $ref_array['amountht'] = $element->total_ht;
                                         $ref_array['amountttc'] = $element->total_ttc;
                                     } else {
                                         $ref_array['amountht'] = 0;
                                         $ref_array['amountttc'] = 0;
                                     }
                                 } else {
                                     $ref_array['amountht'] = '';
                                     $ref_array['amountttc'] = '';
                                 }
                                 $ref_array['status'] = $element->getLibStatut(0);
                                 $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs);
                                 foreach ($tmparray as $key => $val) {
                                     try {
                                         $listlines->setVars($key, $val, true, 'UTF-8');
                                     } catch (OdfException $e) {
                                     } catch (SegmentException $e) {
                                     }
                                 }
                                 $listlines->merge();
                             }
                         }
                     }
                     $odfHandler->mergeSegment($listlines);
                 }
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace labels translated
             $tmparray = $outputlangs->get_translations_for_substitutions();
             foreach ($tmparray as $key => $value) {
                 try {
                     $odfHandler->setVars($key, $value, true, 'UTF-8');
                 } catch (OdfException $e) {
                 }
             }
             // Call the beforeODTSave hook
             $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
             $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             // Write new file
             if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
                 try {
                     $odfHandler->exportAsAttachedPDF($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             } else {
                 try {
                     $odfHandler->saveToDisk($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             }
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             $odfHandler = null;
             // Destroy object
             return 1;
             // Success
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return -1;
         }
     }
     return -1;
 }
*/
$sql = "SELECT rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople";
$resql = $db->query($sql);
if ($resql) {
    $num = $db->num_rows($resql);
    $i = 0;
    $ldap = new Ldap();
    $ldap->connect_bind();
    while ($i < $num) {
        $ldap->error = "";
        $obj = $db->fetch_object($resql);
        $contact = new Contact($db);
        $contact->id = $obj->rowid;
        $contact->fetch($contact->id);
        print $langs->trans("UpdateContact") . " rowid=" . $contact->id . " " . $contact->getFullName($langs);
        $oldobject = $contact;
        $oldinfo = $oldobject->_load_ldap_info();
        $olddn = $oldobject->_load_ldap_dn($oldinfo);
        $info = $contact->_load_ldap_info();
        $dn = $contact->_load_ldap_dn($info);
        $result = $ldap->add($dn, $info, $user);
        // Wil fail if already exists
        $result = $ldap->update($dn, $info, $user, $olddn);
        if ($result > 0) {
            print " - " . $langs->trans("OK");
        } else {
            $error++;
            print " - " . $langs->trans("KO") . ' - ' . $ldap->error;
        }
        print "\n";
예제 #6
0
}
// instantiate Silex app, add twig capability to app
$app = new Silex\Application();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
// ======
// routes
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('contacts' => Contact::getAll()));
});
$app->get("/add_contact", function () use($app) {
    return $app['twig']->render('index.html.twig', array('form' => true));
});
$app->post("/add_contact_success", function () use($app) {
    $new_contact = new Contact($_POST['first_name'], $_POST['last_name'], $_POST['email'], $_POST['phone'], $_POST['street_address'], $_POST['city'], $_POST['state'], $_POST['zip_code'], $_POST['notes']);
    $new_contact->saveContact();
    return $app['twig']->render('index.html.twig', array('contacts' => Contact::getAll(), 'message' => array('type' => 'success', 'text' => $new_contact->getFullName() . ' has been added to your address book.')));
});
$app->get("/delete_contact", function () use($app) {
    return $app['twig']->render('index.html.twig', array('contacts' => Contact::getAll(), 'delete' => true));
});
$app->post("/delete_contact_success", function () use($app) {
    foreach ($_SESSION['list_of_contacts'] as $key => $contact) {
        if ($contact->getContactID() == $_POST['delete_contact']) {
            break;
        }
    }
    $name_of_deleted = $_SESSION['list_of_contacts'][$key]->getFullName();
    $_SESSION['list_of_contacts'][$key]->deleteContact();
    return $app['twig']->render('index.html.twig', array('contacts' => Contact::getAll(), 'message' => array('type' => 'danger', 'text' => $name_of_deleted . ' has been successfully removed from your address book.')));
});
$app->get("/delete_all_contacts", function () use($app) {
예제 #7
0
// Security check
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$contact = new Contact($db);
$result = $contact->fetch($id);
$physicalperson = 1;
$company = new Societe($db);
if ($contact->socid) {
    $result = $company->fetch($contact->socid);
    //print "ee";
}
// We create VCard
$v = new vCard();
$v->setProdId('Dolibarr ' . DOL_VERSION);
$v->setUid('DOLIBARR-CONTACTID-' . $contact->id);
$v->setName($contact->lastname, $contact->firstname, "", "", "");
$v->setFormattedName($contact->getFullName($langs));
// By default, all informations are for work (except phone_perso and phone_mobile)
$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE");
$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE");
$v->setPhoneNumber($contact->fax, "WORK;FAX");
$v->setAddress("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK;POSTAL");
$v->setLabel("", "", $contact->address, $contact->town, "", $contact->zip, $contact->country_code ? $contact->country_id : '', "WORK");
$v->setEmail($contact->email, 'internet,pref');
$v->setNote($contact->note);
$v->setTitle($contact->poste);
// Data from linked company
if ($company->id) {
    $v->setURL($company->url, "WORK");
    if (!$contact->phone_pro) {
        $v->setPhoneNumber($company->phone, "WORK;VOICE");
    }
예제 #8
0
	/**
	 *      Load data of box into memory for a future usage
	 *      @param      $max        Maximum number of records to show
	 */
	function loadBox($max=5)
	{
		global $user, $langs, $db, $conf;
		$langs->load("boxes");

		$this->max=$max;

		$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts",$max));

		if ($user->rights->societe->lire)
		{
			$sql = "SELECT s.rowid, s.name, s.firstname, s.civilite, s.datec, s.tms";
			$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as s";
			if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
			$sql.= " WHERE s.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 s.tms DESC";
			$sql.= $db->plimit($max, 0);

			$result = $db->query($sql);

			if ($result)
			{
				$num = $db->num_rows($result);

				$contactstatic=new Contact($db);

				$i = 0;
				while ($i < $num)
				{
					$objp = $db->fetch_object($result);
					$datec=$db->jdate($objp->datec);
					$datem=$db->jdate($objp->tms);

					$contactstatic->name=$objp->name;
                    $contactstatic->firstname=$objp->firstname;
                    $contactstatic->civilite_id=$objp->civilite;

					$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
                    'logo' => $this->boximg,
                    'url' => DOL_URL_ROOT."/contact/fiche.php?id=".$objp->rowid);

					$this->info_box_contents[$i][1] = array('td' => 'align="left"',
                    'text' => $contactstatic->getFullName($langs,1),
                    'url' => DOL_URL_ROOT."/contact/fiche.php?id=".$objp->rowid);

					$this->info_box_contents[$i][2] = array('td' => 'align="right"',
					'text' => dol_print_date($datem, "day"));

					$i++;
				}

				if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedContacts"));
			}
			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('align' => 'left',
            'text' => $langs->trans("ReadPermissionNotAllowed"));
		}

	}
예제 #9
0
 /**
  *    \brief      Affiche formulaire de selection des contacts
  *    \param      page        Page
  *    \param      selected    Id contact pre-selectionne
  *    \param      htmlname    Nom du formulaire select
  */
 function form_contacts($page, $societe, $selected = '', $htmlname = 'contactidp')
 {
     global $langs;
     if ($htmlname != "none") {
         print '<form method="post" action="' . $page . '">';
         print '<input type="hidden" name="action" value="set_contact">';
         print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
         print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
         print '<tr><td>';
         $num = $this->select_contacts($societe->id, $selected, $htmlname);
         if ($num == 0) {
             print '<font class="error">Cette societe n\'a pas de contact, veuillez en cr�er un avant de faire votre proposition commerciale</font><br>';
             print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $societe->id . '&amp;action=create&amp;backtoreferer=1">' . $langs->trans('AddContact') . '</a>';
         }
         print '</td>';
         print '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
         print '</tr></table></form>';
     } else {
         if ($selected) {
             require_once DOL_DOCUMENT_ROOT . "/contact/class/contact.class.php";
             //$this->load_cache_contacts();
             //print $this->cache_contacts[$selected];
             $contact = new Contact($this->db);
             $contact->fetch($selected);
             print $contact->getFullName($langs);
         } else {
             print "&nbsp;";
         }
     }
 }
 /**
  * Define array with couple subtitution key => subtitution value
  *
  * @param	Contact 		$object        	contact
  * @param	Translate 	$outputlangs   	object for output
  * @param   array_key	$array_key	    Name of the key for return array
  * @return	array of substitution key->code
  */
 function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object')
 {
     global $conf;
     if (empty($object->country) && !empty($object->country_code)) {
         $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code);
     }
     if (empty($object->state) && !empty($object->state_code)) {
         $object->state = getState($object->state_code, 0);
     }
     $array_contact = array($array_key . '_fullname' => $object->getFullName($outputlangs, 1), $array_key . '_lastname' => $object->lastname, $array_key . '_firstname' => $object->firstname, $array_key . '_address' => $object->address, $array_key . '_zip' => $object->zip, $array_key . '_town' => $object->town, $array_key . '_state_id' => $object->state_id, $array_key . '_state_code' => $object->state_code, $array_key . '_state' => $object->state, $array_key . '_country_id' => $object->country_id, $array_key . '_country_code' => $object->country_code, $array_key . '_country' => $object->country, $array_key . '_poste' => $object->poste, $array_key . '_socid' => $object->socid, $array_key . '_statut' => $object->statut, $array_key . '_code' => $object->code, $array_key . '_email' => $object->email, $array_key . '_jabberid' => $object->jabberid, $array_key . '_phone_pro' => $object->phone_pro, $array_key . '_phone_perso' => $object->phone_perso, $array_key . '_phone_mobile' => $object->phone_mobile, $array_key . '_fax' => $object->fax, $array_key . '_birthday' => $object->birthday, $array_key . '_default_lang' => $object->default_lang, $array_key . '_note_public' => $object->note_public, $array_key . '_note_private' => $object->note_private);
     // Retrieve extrafields
     require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
     $extrafields = new ExtraFields($this->db);
     $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
     $object->fetch_optionals($object->id, $extralabels);
     foreach ($extrafields->attribute_label as $key => $label) {
         if ($extrafields->attribute_type[$key] == 'price') {
             $object->array_options['options_' . $key] = price($object->array_options['options_' . $key], 0, $outputlangs, 0, 0, -1, $conf->currency);
         } elseif ($extrafields->attribute_type[$key] == 'select') {
             $object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]];
         }
         $array_contact = array_merge($array_contact, array($array_key . '_options_' . $key => $object->array_options['options_' . $key]));
     }
     return $array_contact;
 }
/**
 * 		Show html area for list of contacts
 *
 *		@param	Conf		$conf		Object conf
 * 		@param	Translate	$langs		Object langs
 * 		@param	DoliDB		$db			Database handler
 * 		@param	Object		$object		Third party object
 *      @param  string		$backtopage	Url to go once contact is created
 *      @return	void
 */
function show_contacts($conf, $langs, $db, $object, $backtopage = '')
{
    global $user, $conf;
    global $bc;
    $form = new Form($db);
    $sortfield = GETPOST("sortfield", 'alpha');
    $sortorder = GETPOST("sortorder", 'alpha');
    $search_status = GETPOST("search_status", 'int');
    if ($search_status == '') {
        $search_status = 1;
    }
    // always display activ customer first
    $search_name = GETPOST("search_name", 'alpha');
    if (!$sortorder) {
        $sortorder = "ASC";
    }
    if (!$sortfield) {
        $sortfield = "p.lastname";
    }
    $i = -1;
    $contactstatic = new Contact($db);
    if (!empty($conf->clicktodial->enabled)) {
        $user->fetch_clicktodial();
        // lecture des infos de clicktodial
    }
    $buttoncreate = '';
    if ($user->rights->societe->contact->creer) {
        $addcontact = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress");
        $buttoncreate = '<a class="addnewrecord" href="' . DOL_URL_ROOT . '/contact/fiche.php?socid=' . $object->id . '&amp;action=create&amp;backtopage=' . urlencode($backtopage) . '">' . $addcontact;
        if (empty($conf->dol_optimize_smallscreen)) {
            $buttoncreate .= ' ' . img_picto($addcontact, 'filenew');
        }
        $buttoncreate .= '</a>' . "\n";
    }
    print "\n";
    $title = !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ContactsForCompany") : $langs->trans("ContactsAddressesForCompany");
    print_fiche_titre($title, $buttoncreate, '');
    print '<form method="GET" action="' . $_SERVER["PHP_SELF"] . '" name="formfilter">';
    print '<input type="hidden" name="socid" value="' . $object->id . '">';
    print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
    print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
    print "\n" . '<table class="noborder" width="100%">' . "\n";
    $param = "socid=" . $object->id;
    if ($search_status != '') {
        $param .= '&amp;search_status=' . $search_status;
    }
    if ($search_name != '') {
        $param .= '&amp;search_name=' . urlencode($search_name);
    }
    $colspan = 9;
    print '<tr class="liste_titre">';
    print_liste_field_titre($langs->trans("Name"), $_SERVER["PHP_SELF"], "p.lastname", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Poste"), $_SERVER["PHP_SELF"], "p.poste", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("PhonePro"), $_SERVER["PHP_SELF"], "p.phone", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("PhoneMobile"), $_SERVER["PHP_SELF"], "p.phone_mobile", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("Fax"), $_SERVER["PHP_SELF"], "p.fax", "", $param, '', $sortfield, $sortorder);
    print_liste_field_titre($langs->trans("EMail"), $_SERVER["PHP_SELF"], "p.email", "", $param, '', $sortfield, $sortorder);
    if (!empty($conf->skype->enabled)) {
        $colspan++;
        print '<td>' . $langs->trans("Skype") . '</td>';
    }
    print_liste_field_titre($langs->trans("Status"), $_SERVER["PHP_SELF"], "p.statut", "", $param, '', $sortfield, $sortorder);
    // Copy to clipboard
    print "<td>&nbsp;</td>";
    // Add to agenda
    if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Edit
    print '<td>&nbsp;</td>';
    print "</tr>";
    print '<tr class="liste_titre">';
    print '<td class="liste_titre">';
    print '<input type="text" class="flat" name="search_name" size="20" value="' . $search_name . '">';
    print '</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    print '<td>&nbsp;</td>';
    if (!empty($conf->skype->enabled)) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Status
    print '<td class="liste_titre maxwidthonsmartphone">';
    print $form->selectarray('search_status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $search_status);
    print '</td>';
    // Copy to clipboard
    print "<td>&nbsp;</td>";
    // Add to agenda
    if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
        $colspan++;
        print '<td>&nbsp;</td>';
    }
    // Edit
    print '<td class="liste_titre" align="right">';
    print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
    print '</td>';
    print "</tr>";
    $sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.poste, p.phone, p.phone_mobile, p.fax, p.email, p.skype, p.statut ";
    $sql .= ", p.civilite as civility_id, p.address, p.zip, p.town";
    $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as p";
    $sql .= " WHERE p.fk_soc = " . $object->id;
    if ($search_status != '') {
        $sql .= " AND p.statut = " . $db->escape($search_status);
    }
    if ($search_name) {
        $sql .= " AND (p.lastname LIKE '%" . $db->escape($search_name) . "%' OR p.firstname LIKE '%" . $db->escape($search_name) . "%')";
    }
    $sql .= " ORDER BY {$sortfield} {$sortorder}";
    dol_syslog('core/lib/company.lib.php :: show_contacts sql=' . $sql, LOG_DEBUG);
    $result = $db->query($sql);
    $num = $db->num_rows($result);
    $var = true;
    if ($num) {
        $i = 0;
        while ($i < $num) {
            $obj = $db->fetch_object($result);
            $var = !$var;
            print "<tr " . $bc[$var] . ">";
            print '<td>';
            $contactstatic->id = $obj->rowid;
            $contactstatic->statut = $obj->statut;
            $contactstatic->lastname = $obj->lastname;
            $contactstatic->firstname = $obj->firstname;
            $contactstatic->civility_id = $obj->civility_id;
            print $contactstatic->getNomUrl(1);
            print '</td>';
            print '<td>' . $obj->poste . '</td>';
            $country_code = getCountry($obj->country_id, 'all');
            // Lien click to dial
            print '<td>';
            print dol_print_phone($obj->phone, $country_code['code'], $obj->rowid, $object->id, 'AC_TEL');
            print '</td>';
            print '<td>';
            print dol_print_phone($obj->phone_mobile, $country_code['code'], $obj->rowid, $object->id, 'AC_TEL');
            print '</td>';
            print '<td>';
            print dol_print_phone($obj->fax, $country_code['code'], $obj->rowid, $object->id, 'AC_FAX');
            print '</td>';
            print '<td>';
            print dol_print_email($obj->email, $obj->rowid, $object->id, 'AC_EMAIL');
            print '</td>';
            if (!empty($conf->skype->enabled)) {
                print '<td>';
                print dol_print_skype($obj->skype, $obj->rowid, $object->id, 'AC_SKYPE');
                print '</td>';
            }
            // Status
            print '<td>' . $contactstatic->getLibStatut(5) . '</td>';
            print '<td align="center">';
            if (!empty($conf->use_javascript_ajax)) {
                // Copy to clipboard
                $coords = '';
                if (!empty($object->name)) {
                    $coords .= $object->name . "<br>";
                }
                $coords .= $contactstatic->getFullName($langs, 1) . ' ';
                $coords .= "<br>";
                if (!empty($obj->address)) {
                    $coords .= dol_nl2br($obj->address, 1, true) . "<br>";
                    if (!empty($obj->zip)) {
                        $coords .= $obj->zip . ' ';
                    }
                    if (!empty($obj->town)) {
                        $coords .= $obj->town;
                    }
                    if (!empty($obj->country_id)) {
                        $coords .= "<br>" . $country_code['label'];
                    }
                } else {
                    if (!empty($object->address)) {
                        $coords .= dol_nl2br($object->address, 1, true) . "<br>";
                        if (!empty($object->zip)) {
                            $coords .= $object->zip . ' ';
                        }
                        if (!empty($object->town)) {
                            $coords .= $object->town;
                        }
                        if (!empty($object->country_id)) {
                            $coords .= "<br>" . $country_code['label'];
                        }
                    }
                }
                // hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
                print '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\'' . dol_escape_js($coords) . '\',\'' . dol_escape_js($langs->trans("HelpCopyToClipboard")) . '\');">';
                print img_picto($langs->trans("Address"), 'object_address.png');
                print '</a>';
            }
            print '</td>';
            // Add to agenda
            if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
                print '<td align="center">';
                if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
                    print '<a class="hideonsmartphone" href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&actioncode=AC_RDV&contactid=' . $obj->rowid . '&socid=' . $object->id . '&backtopage=' . urlencode($backtopage) . '">';
                    print img_object($langs->trans("Rendez-Vous"), "action_rdv");
                    print '</a> ';
                }
                print '<a href="' . DOL_URL_ROOT . '/comm/action/fiche.php?action=create&actioncode=&contactid=' . $obj->rowid . '&socid=' . $object->id . '&backtopage=' . urlencode($backtopage) . '">';
                print img_object($langs->trans("Event"), "action");
                print '</a></td>';
            }
            // Edit
            if ($user->rights->societe->contact->creer) {
                print '<td align="right">';
                print '<a href="' . DOL_URL_ROOT . '/contact/fiche.php?action=edit&amp;id=' . $obj->rowid . '&amp;backtopage=' . urlencode($backtopage) . '">';
                print img_edit();
                print '</a></td>';
            } else {
                print '<td>&nbsp;</td>';
            }
            print "</tr>\n";
            $i++;
        }
    } else {
        print "<tr " . $bc[$var] . ">";
        print '<td colspan="' . $colspan . '">' . $langs->trans("None") . '</td>';
        print "</tr>\n";
    }
    print "\n</table>\n";
    print '</form>' . "\n";
    print "<br>\n";
    ?>
<div id="dialog" title="<?php 
    echo dol_escape_htmltag($langs->trans('Address'));
    ?>
" style="display: none;"></div>
<?php 
    return $i;
}
 /**
  *
  * @param unknown $object
  */
 static function sendOrderByMail(&$object)
 {
     global $conf, $langs, $user, $db;
     if (empty($object->thirdparty)) {
         $object->fetch_thirdparty();
     }
     $sendto = $object->thirdparty->email;
     $sendtocc = '';
     $from = empty($user->email) ? $conf->global->MAIN_MAIL_EMAIL_FROM : $user->email;
     $id = $object->id;
     $_POST['receiver'] = '-1';
     $_POST['frommail'] = $_POST['replytomail'] = $from;
     $_POST['fromname'] = $_POST['replytoname'] = $user->getFullName($langs);
     dol_include_once('/core/class/html.formmail.class.php');
     $formmail = new Formmail($db);
     $outputlangs = clone $langs;
     $id_template = (int) $conf->global->GRAPEFRUIT_SEND_BILL_BY_MAIL_ON_VALIDATE_MODEL;
     $formmail->fetchAllEMailTemplate('facture_send', $user, $outputlangs);
     foreach ($formmail->lines_model as &$model) {
         if ($model->id == $id_template) {
             break;
         }
     }
     if (empty($model)) {
         setEventMessage($langs->trans('ModelRequire'), 'errors');
     }
     // Make substitution
     $substit['__REF__'] = $object->ref;
     $substit['__SIGNATURE__'] = $user->signature;
     $substit['__REFCLIENT__'] = $object->ref_client;
     $substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
     $substit['__PROJECT_REF__'] = is_object($object->projet) ? $object->projet->ref : '';
     $substit['__PROJECT_NAME__'] = is_object($object->projet) ? $object->projet->title : '';
     $substit['__PERSONALIZED__'] = '';
     $substit['__CONTACTCIVNAME__'] = '';
     // Find the good contact adress
     $custcontact = '';
     $contactarr = array();
     $contactarr = $object->liste_contact(-1, 'external');
     if (is_array($contactarr) && count($contactarr) > 0) {
         foreach ($contactarr as $contact) {
             dol_syslog(get_class($this) . '::' . __METHOD__ . ' lib=' . $contact['libelle']);
             dol_syslog(get_class($this) . '::' . __METHOD__ . ' trans=' . $langs->trans('TypeContact_commande_external_BILLING'));
             if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_BILLING')) {
                 require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
                 $contactstatic = new Contact($db);
                 $contactstatic->fetch($contact['id']);
                 $custcontact = $contactstatic->getFullName($langs, 1);
                 dol_syslog(get_class($this) . '::' . __METHOD__ . ' email=' . $contactstatic->email);
             }
         }
         if (!empty($custcontact)) {
             $substit['__CONTACTCIVNAME__'] = $custcontact;
         }
         if (!empty($contactstatic->email)) {
             $sendto = $contactstatic->email;
         }
     }
     $topic = make_substitutions($model->topic, $substit);
     $message = make_substitutions($model->content, $substit);
     $_POST['message'] = $message;
     $_POST['subject'] = $topic;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     // Add attached files
     $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $object->ref, preg_quote($object->ref, '/') . '[^\\-]+');
     if (is_array($fileparams) && array_key_exists('fullname', $fileparams) && !empty($fileparams['fullname'])) {
         $_SESSION["listofpaths"] = $fileparams['fullname'];
         $_SESSION["listofnames"] = basename($fileparams['fullname']);
         $_SESSION["listofmimes"] = dol_mimetype($fileparams['fullname']);
     } else {
         // generate invoice
         $result = $object->generateDocument($object->modelpdf, $outputlangs, 0, 0, 0);
         if ($result <= 0) {
             $this->error = $object->error;
         }
         $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $object->ref, preg_quote($object->ref, '/') . '[^\\-]+');
         if (is_array($fileparams) && array_key_exists('fullname', $fileparams) && !empty($fileparams['fullname'])) {
             $_SESSION["listofpaths"] = $fileparams['fullname'];
             $_SESSION["listofnames"] = basename($fileparams['fullname']);
             $_SESSION["listofmimes"] = dol_mimetype($fileparams['fullname']);
         }
     }
     $action = 'send';
     $actiontypecode = 'AC_FAC';
     $trigger_name = 'BILL_SENTBYMAIL';
     $paramname = 'id';
     $mode = 'emailfrominvoice';
     if (!empty($sendto)) {
         require_once __DIR__ . '/../tpl/actions_sendmails.inc.php';
     }
 }
예제 #13
0
	}
	else
	{
		$result=$cactioncomm->fetch($_POST["actioncode"]);
	}

	// Initialisation objet actioncomm
	$actioncomm->type_id = $cactioncomm->id;
	$actioncomm->type_code = $cactioncomm->code;
	$actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0;
	$actioncomm->fulldayevent = $_POST["fullday"]?1:0;
	$actioncomm->location = isset($_POST["location"])?$_POST["location"]:'';
	$actioncomm->label = trim($_POST["label"]);
	if (! $_POST["label"])
	{
		if ($_POST["actioncode"] == 'AC_RDV' && $contact->getFullName($langs))
		{
			$actioncomm->label = $langs->transnoentitiesnoconv("TaskRDVWith",$contact->getFullName($langs));
		}
		else
		{
			if ($langs->trans("Action".$actioncomm->type_code) != "Action".$actioncomm->type_code)
			{
				$actioncomm->label = $langs->transnoentitiesnoconv("Action".$actioncomm->type_code)."\n";
			}
			else $actioncomm->label = $cactioncomm->libelle;
		}
	}
	$actioncomm->fk_project = isset($_POST["projectid"])?$_POST["projectid"]:0;
	$actioncomm->datep = $datep;
	$actioncomm->datef = $datef;
예제 #14
0
파일: card.php 프로젝트: Albertopf/prueba
     $donotclearsession = 1;
     $action = 'create';
     setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
 } else {
     $object->type_code = GETPOST('actioncode');
 }
 if (!$error) {
     // Initialisation objet actioncomm
     $object->priority = GETPOST("priority") ? GETPOST("priority") : 0;
     $object->fulldayevent = !empty($fulldayevent) ? 1 : 0;
     $object->location = GETPOST("location");
     $object->label = trim(GETPOST('label'));
     $object->fk_element = GETPOST("fk_element");
     $object->elementtype = GETPOST("elementtype");
     if (!GETPOST('label')) {
         if (GETPOST('actioncode') == 'AC_RDV' && $contact->getFullName($langs)) {
             $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs));
         } else {
             if ($langs->trans("Action" . $object->type_code) != "Action" . $object->type_code) {
                 $object->label = $langs->transnoentitiesnoconv("Action" . $object->type_code) . "\n";
             } else {
                 $object->label = $cactioncomm->libelle;
             }
         }
     }
     $object->fk_project = isset($_POST["projectid"]) ? $_POST["projectid"] : 0;
     $object->datep = $datep;
     $object->datef = $datef;
     $object->percentage = $percentage;
     $object->duree = ((double) (GETPOST('dureehour') * 60) + (double) GETPOST('dureemin')) * 60;
     $transparency = GETPOST("transparency") == 'on' ? 1 : 0;
 /**
  *	Function to build a document on disk using the generic odt module.
  *
  *	@param	Commande	$object					Object source to build document
  *	@param	Translate	$outputlangs			Lang output object
  * 	@param	string		$srctemplatepath	    Full path of source filename for generator using a template file
  *	@return	int         						1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs, $srctemplatepath)
 {
     global $user, $langs, $conf, $mysoc, $hookmanager;
     if (empty($srctemplatepath)) {
         dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
         return -1;
     }
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     $sav_charset_output = $outputlangs->charset_output;
     $outputlangs->charset_output = 'UTF-8';
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("projects");
     if ($conf->projet->dir_output) {
         // If $object is id instead of object
         if (!is_object($object)) {
             $id = $object;
             $object = new Task($this->db);
             $result = $object->fetch($id);
             if ($result < 0) {
                 dol_print_error($this->db, $object->error);
                 return -1;
             }
         }
         $project = new Project($this->db);
         $project->fetch($object->fk_project);
         $dir = $conf->projet->dir_output . "/" . $project->ref . "/";
         $objectref = dol_sanitizeFileName($object->ref);
         if (!preg_match('/specimen/i', $objectref)) {
             $dir .= "/" . $objectref;
         }
         $file = $dir . "/" . $objectref . ".odt";
         if (!file_exists($dir)) {
             print '$dir' . $dir;
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return -1;
             }
         }
         if (file_exists($dir)) {
             //print "srctemplatepath=".$srctemplatepath;	// Src filename
             $newfile = basename($srctemplatepath);
             $newfiletmp = preg_replace('/\\.(ods|odt)/i', '', $newfile);
             $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
             $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
             $newfiletmp = $objectref . '_' . $newfiletmp;
             //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
             $file = $dir . '/' . $newfiletmp . '.odt';
             //print "newdir=".$dir;
             //print "newfile=".$newfile;
             //print "file=".$file;
             //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
             dol_mkdir($conf->projet->dir_temp);
             $socobject = $object->thirdparty;
             // Make substitution
             $substitutionarray = array('__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email);
             complete_substitutions_array($substitutionarray, $langs, $object);
             // Open and load template
             require_once ODTPHP_PATH . 'odf.php';
             try {
                 $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->projet->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
             } catch (Exception $e) {
                 $this->error = $e->getMessage();
                 return -1;
             }
             // After construction $odfHandler->contentXml contains content and
             // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
             // [!-- BEGIN lines --]*[!-- END lines --]
             //print html_entity_decode($odfHandler->__toString());
             //print exit;
             // Make substitutions into odt of user info
             $array_user = $this->get_substitutionarray_user($user, $outputlangs);
             $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
             $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
             $array_objet = $this->get_substitutionarray_object($project, $outputlangs);
             $array_other = $this->get_substitutionarray_other($outputlangs);
             $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
             complete_substitutions_array($tmparray, $outputlangs, $object);
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Replace tags of lines for tasks
             try {
                 // Security check
                 $socid = 0;
                 if (!empty($project->fk_soc)) {
                     $socid = $project->fk_soc;
                 }
                 $tmparray = $this->get_substitutionarray_tasks($object, $outputlangs);
                 complete_substitutions_array($tmparray, $outputlangs, $object);
                 foreach ($tmparray as $key => $val) {
                     try {
                         $odfHandler->setVars($key, $val, true, 'UTF-8');
                     } catch (OdfException $e) {
                     } catch (SegmentException $e) {
                     }
                 }
                 // Replace tags of lines for contacts task
                 $sourcearray = array('internal', 'external');
                 $contact_arrray = array();
                 foreach ($sourcearray as $source) {
                     $contact_temp = $object->liste_contact(-1, $source);
                     if (is_array($contact_temp) && count($contact_temp) > 0) {
                         $contact_arrray = array_merge($contact_arrray, $contact_temp);
                     }
                 }
                 if (is_array($contact_arrray) && count($contact_arrray) > 0) {
                     $listlinestaskres = $odfHandler->setSegment('tasksressources');
                     foreach ($contact_arrray as $contact) {
                         if ($contact['source'] == 'internal') {
                             $objectdetail = new User($this->db);
                             $objectdetail->fetch($contact['id']);
                             $contact['socname'] = $mysoc->name;
                         } elseif ($contact['source'] == 'external') {
                             $objectdetail = new Contact($this->db);
                             $objectdetail->fetch($contact['id']);
                             $soc = new Societe($this->db);
                             $soc->fetch($contact['socid']);
                             $contact['socname'] = $soc->name;
                         }
                         $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
                         $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
                         foreach ($tmparray as $key => $val) {
                             try {
                                 $listlinestaskres->setVars($key, $val, true, 'UTF-8');
                             } catch (OdfException $e) {
                             } catch (SegmentException $e) {
                             }
                         }
                         $listlinestaskres->merge();
                     }
                     $odfHandler->mergeSegment($listlinestaskres);
                 }
                 //Time ressources
                 $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
                 $sql .= ", u.name, u.firstname";
                 $sql .= " FROM " . MAIN_DB_PREFIX . "projet_task_time as t";
                 $sql .= " , " . MAIN_DB_PREFIX . "user as u";
                 $sql .= " WHERE t.fk_task =" . $object->id;
                 $sql .= " AND t.fk_user = u.rowid";
                 $sql .= " ORDER BY t.task_date DESC";
                 $resql = $this->db->query($sql);
                 if ($resql) {
                     $num = $this->db->num_rows($resql);
                     $i = 0;
                     $tasks = array();
                     $listlinestasktime = $odfHandler->setSegment('taskstimes');
                     while ($i < $num) {
                         $row = $this->db->fetch_array($resql);
                         if (!empty($row['fk_user'])) {
                             $objectdetail = new User($this->db);
                             $objectdetail->fetch($row['fk_user']);
                             $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
                         } else {
                             $row['fullcivname'] = '';
                         }
                         $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
                         foreach ($tmparray as $key => $val) {
                             try {
                                 $listlinestasktime->setVars($key, $val, true, 'UTF-8');
                             } catch (OdfException $e) {
                             } catch (SegmentException $e) {
                             }
                         }
                         $listlinestasktime->merge();
                         $i++;
                     }
                     $this->db->free($resql);
                     $odfHandler->mergeSegment($listlinestasktime);
                 }
                 // Replace tags of project files
                 $listtasksfiles = $odfHandler->setSegment('tasksfiles');
                 $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($project->ref) . '/' . dol_sanitizeFileName($object->ref);
                 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1);
                 foreach ($filearray as $filedetail) {
                     $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
                     //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
                     foreach ($tmparray as $key => $val) {
                         try {
                             $listtasksfiles->setVars($key, $val, true, 'UTF-8');
                         } catch (OdfException $e) {
                         } catch (SegmentException $e) {
                         }
                     }
                     $listtasksfiles->merge();
                 }
                 //$listlines->merge();
                 $odfHandler->mergeSegment($listtasksfiles);
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace tags of project files
             try {
                 $listlines = $odfHandler->setSegment('projectfiles');
                 $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref);
                 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', 'name', SORT_ASC, 1);
                 foreach ($filearray as $filedetail) {
                     //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
                     $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
                     foreach ($tmparray as $key => $val) {
                         try {
                             $listlines->setVars($key, $val, true, 'UTF-8');
                         } catch (OdfException $e) {
                         } catch (SegmentException $e) {
                         }
                     }
                     $listlines->merge();
                 }
                 $odfHandler->mergeSegment($listlines);
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace tags of lines for contacts
             $sourcearray = array('internal', 'external');
             $contact_arrray = array();
             foreach ($sourcearray as $source) {
                 $contact_temp = $project->liste_contact(-1, $source);
                 if (is_array($contact_temp) && count($contact_temp) > 0) {
                     $contact_arrray = array_merge($contact_arrray, $contact_temp);
                 }
             }
             if (is_array($contact_arrray) && count($contact_arrray) > 0) {
                 try {
                     $listlines = $odfHandler->setSegment('projectcontacts');
                     foreach ($contact_arrray as $contact) {
                         if ($contact['source'] == 'internal') {
                             $objectdetail = new User($this->db);
                             $objectdetail->fetch($contact['id']);
                             $contact['socname'] = $mysoc->name;
                         } elseif ($contact['source'] == 'external') {
                             $objectdetail = new Contact($this->db);
                             $objectdetail->fetch($contact['id']);
                             $soc = new Societe($this->db);
                             $soc->fetch($contact['socid']);
                             $contact['socname'] = $soc->name;
                         }
                         $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
                         $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
                         foreach ($tmparray as $key => $val) {
                             try {
                                 $listlines->setVars($key, $val, true, 'UTF-8');
                             } catch (OdfException $e) {
                             } catch (SegmentException $e) {
                             }
                         }
                         $listlines->merge();
                     }
                     $odfHandler->mergeSegment($listlines);
                 } catch (OdfException $e) {
                     $this->error = $e->getMessage();
                     dol_syslog($this->error, LOG_WARNING);
                     return -1;
                 }
             }
             // Call the beforeODTSave hook
             $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
             $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             // Write new file
             if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
                 try {
                     $odfHandler->exportAsAttachedPDF($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             } else {
                 try {
                     $odfHandler->saveToDisk($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             }
             $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             $odfHandler = null;
             // Destroy object
             return 1;
             // Success
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return -1;
         }
     }
     return -1;
 }
예제 #16
0
 $formmail->substit['__PROJECT_REF__'] = is_object($object->projet) ? $object->projet->ref : '';
 $formmail->substit['__PROJECT_NAME__'] = is_object($object->projet) ? $object->projet->title : '';
 $formmail->substit['__PERSONALIZED__'] = '';
 $formmail->substit['__CONTACTCIVNAME__'] = '';
 // Find the good contact adress
 $custcontact = '';
 $contactarr = array();
 $contactarr = $object->liste_contact(-1, 'external');
 if (is_array($contactarr) && count($contactarr) > 0) {
     foreach ($contactarr as $contact) {
         if ($contact['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) {
             // TODO Use code and not label
             require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
             $contactstatic = new Contact($db);
             $contactstatic->fetch($contact['id']);
             $custcontact = $contactstatic->getFullName($langs, 1);
         }
     }
     if (!empty($custcontact)) {
         $formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
     }
 }
 // Tableau des parametres complementaires du post
 $formmail->param['action'] = $action;
 $formmail->param['models'] = $modelmail;
 $formmail->param['models_id'] = GETPOST('modelmailselected', 'int');
 $formmail->param['facid'] = $object->id;
 $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id;
 // Init list of files
 if (GETPOST("mode") == 'init') {
     $formmail->clear_attached_files();
예제 #17
0
 function select_contacts_combobox($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $forcecombo = 0, $event = array())
 {
     global $conf, $langs;
     $langs->load('companies');
     $out = '';
     // On recherche les societes
     $sql = "SELECT sp.rowid, sp.nom as name ";
     $sql .= " FROM " . MAIN_DB_PREFIX . "societe as sp";
     $sql .= " WHERE sp.entity IN (" . getEntity('societe', 1) . ")";
     if ($socid > 0) {
         $sql .= " AND sp.fk_soc=" . $socid;
     }
     $sql .= " ORDER BY sp.nom ASC";
     dol_syslog(get_class($this) . "::select_contacts_combobox sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->num_rows($resql);
         if ($conf->use_javascript_ajax && $conf->global->AGF_CONTACT_USE_SEARCH_TO_SELECT && !$forcecombo) {
             $out .= ajax_combobox($htmlname, $event);
         }
         if ($htmlname != 'none' || $options_only) {
             $out .= '<select class="flat' . ($moreclass ? ' ' . $moreclass : '') . '" id="' . $htmlname . '" name="' . $htmlname . '">';
         }
         if ($showempty) {
             $out .= '<option value="0"></option>';
         }
         $num = $this->db->num_rows($resql);
         $i = 0;
         if ($num) {
             include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
             $contactstatic = new Contact($this->db);
             while ($i < $num) {
                 $obj = $this->db->fetch_object($resql);
                 $contactstatic->id = $obj->rowid;
                 $contactstatic->name = $obj->name;
                 $contactstatic->lastname = $obj->name;
                 if ($htmlname != 'none') {
                     $disabled = 0;
                     if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
                         $disabled = 1;
                     }
                     if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
                         $disabled = 1;
                     }
                     if ($selected && $selected == $obj->rowid) {
                         $out .= '<option value="' . $obj->rowid . '"';
                         if ($disabled) {
                             $out .= ' disabled="disabled"';
                         }
                         $out .= ' selected="selected">';
                         $out .= $contactstatic->getFullName($langs);
                         if ($showfunction && $obj->poste) {
                             $out .= ' (' . $obj->poste . ')';
                         }
                         $out .= '</option>';
                     } elseif (!$disabled) {
                         $out .= '<option value="' . $obj->rowid . '"';
                         if ($disabled) {
                             $out .= ' disabled="disabled"';
                         }
                         $out .= '>';
                         $out .= $contactstatic->getFullName($langs);
                         if ($showfunction && $obj->poste) {
                             $out .= ' (' . $obj->poste . ')';
                         }
                         $out .= '</option>';
                     }
                 } else {
                     if ($selected == $obj->rowid) {
                         $out .= $contactstatic->getFullName($langs);
                         if ($showfunction && $obj->poste) {
                             $out .= ' (' . $obj->poste . ')';
                         }
                     }
                 }
                 $i++;
             }
         } else {
             $out .= '<option value="-1" selected="selected" disabled="disabled">' . $langs->trans("NoContactDefined") . '</option>';
         }
         if ($htmlname != 'none' || $options_only) {
             $out .= '</select>';
         }
         $this->num = $num;
         return $out;
     } else {
         dol_print_error($this->db);
         return -1;
     }
 }