Example #1
0
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/supplier_proposal.lib.php';
$langs->load('supplier_proposal');
$langs->load('compta');
$langs->load('bills');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'supplier_proposal', $id, 'supplier_proposal');
$object = new SupplierProposal($db);
/******************************************************************************/
/*                     Actions                                                */
/******************************************************************************/
$permissionnote = $user->rights->supplier_proposal->creer;
// Used by the include of actions_setnotes.inc.php
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php';
// Must be include, not includ_once
/******************************************************************************/
/* Affichage fiche                                                            */
/******************************************************************************/
llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
    if ($mesg) {
        print $mesg;
Example #2
0
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php';
$langs->load("supplier_proposal");
$langs->load("companies");
// Security check
$socid = GETPOST('socid', 'int');
if (isset($user->societe_id) && $user->societe_id > 0) {
    $action = '';
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'supplier_proposal');
/*
 * View
 */
$now = dol_now();
$supplier_proposalstatic = new SupplierProposal($db);
$companystatic = new Societe($db);
$form = new Form($db);
$formfile = new FormFile($db);
$help_url = "EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
llxHeader("", $langs->trans("SupplierProposalArea"), $help_url);
print load_fiche_titre($langs->trans("SupplierProposalArea"));
print '<div class="fichecenter"><div class="fichethirdleft">';
/*
 * Search form
 */
$var = false;
print '<form method="post" action="' . DOL_URL_ROOT . '/supplier_proposal/list.php">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("SearchRequest") . '</td></tr>';
Example #3
0
 *      \brief      Page d'affichage des infos d'une proposition commerciale
 */
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/supplier_proposal.lib.php';
$langs->load('supplier_proposal');
$langs->load('compta');
$id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
// Security check
if (!empty($user->societe_id)) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'supplier_proposal', $id);
/*
 *	View
 */
llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur');
$object = new SupplierProposal($db);
$object->fetch($id);
$object->fetch_thirdparty();
$head = supplier_proposal_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans('CommRequest'), 0, 'supplier_proposal');
$object->info($object->id);
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();
 /**
  *	Function to build a document on disk using the generic odt module.
  *
  *	@param		Propale		$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
  *  @param		int			$hidedetails		Do not show line details
  *  @param		int			$hidedesc			Do not show desc
  *  @param		int			$hideref			Do not show ref
  *	@return		int         					1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 {
     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("bills");
     if ($conf->supplier_proposal->dir_output) {
         // If $object is id instead of object
         if (!is_object($object)) {
             $id = $object;
             $object = new SupplierProposal($this->db);
             $result = $object->fetch($id);
             if ($result < 0) {
                 dol_print_error($this->db, $object->error);
                 return -1;
             }
         }
         $dir = $conf->supplier_proposal->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;
             // 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->propal->dir_temp=".$conf->propal->dir_temp;
             dol_mkdir($conf->supplier_proposal->dir_temp);
             // If BILLING contact defined on invoice, we use it
             $usecontact = false;
             $arrayidcontact = $object->getIdContact('external', 'BILLING');
             if (count($arrayidcontact) > 0) {
                 $usecontact = true;
                 $result = $object->fetch_contact($arrayidcontact[0]);
             }
             // Recipient name
             if (!empty($usecontact)) {
                 // On peut utiliser le nom de la societe du contact
                 if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                     $socobject = $object->contact;
                 } else {
                     $socobject = $object->client;
                 }
             } else {
                 $socobject = $object->client;
             }
             // Make substitution
             $substitutionarray = array('__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, '__TOTAL_VAT__' => $object->total_vat);
             complete_substitutions_array($substitutionarray, $langs, $object);
             // Call the ODTSubstitution hook
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
             $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             // Line of free text
             $newfreetext = '';
             $paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT';
             if (!empty($conf->global->{$paramfreetext})) {
                 $newfreetext = make_substitutions($conf->global->{$paramfreetext}, $substitutionarray);
             }
             // Open and load template
             require_once ODTPHP_PATH . 'odf.php';
             try {
                 $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->supplier_proposal->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 freetext
             try {
                 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
             } catch (OdfException $e) {
             }
             // Make substitutions into odt
             $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($object, $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);
             // Call the ODTSubstitution hook
             $parameters = array('odfHandler' => &$odfHandler, '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
             try {
                 $listlines = $odfHandler->setSegment('lines');
                 foreach ($object->lines as $line) {
                     $tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
                     complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
                     // Call the ODTSubstitutionLine hook
                     $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $line);
                     $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action);
                     // Note that $action and $object may have been modified by some hooks
                     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, 'substitutionarray' => &$tmparray);
             $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;
                 }
             }
             $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
             $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;
 }
Example #5
0
if ($search_sale > 0) {
    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND c.fk_c_type_contact = tc.rowid AND tc.element='supplier_proposal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = " . $search_user;
}
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ', p.ref DESC';
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
    $result = $db->query($sql);
    $nbtotalofrecords = $db->num_rows($result);
}
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result) {
    $objectstatic = new SupplierProposal($db);
    $userstatic = new User($db);
    $num = $db->num_rows($result);
    if ($socid) {
        $soc = new Societe($db);
        $soc->fetch($socid);
    }
    $param = '&socid=' . $socid . '&viewstatut=' . $viewstatut;
    if ($month) {
        $param .= '&month=' . $month;
    }
    if ($year) {
        $param .= '&year=' . $year;
    }
    if ($search_ref) {
        $param .= '&search_ref=' . $search_ref;
Example #6
0
$max = 5;
$now = dol_now();
/*
 * Actions
 */
/*
 * View
 */
$form = new Form($db);
$formfile = new FormFile($db);
$companystatic = new Societe($db);
if (!empty($conf->propal->enabled)) {
    $propalstatic = new Propal($db);
}
if (!empty($conf->supplier_proposal->enabled)) {
    $supplierproposalstatic = new SupplierProposal($db);
}
if (!empty($conf->commande->enabled)) {
    $orderstatic = new Commande($db);
}
if (!empty($conf->fournisseur->enabled)) {
    $supplierorderstatic = new CommandeFournisseur($db);
}
llxHeader();
print load_fiche_titre($langs->trans("CommercialArea"), '', 'title_commercial.png');
print '<div class="fichecenter"><div class="fichethirdleft">';
// Search proposal
if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
    $listofsearchfields['search_proposal'] = array('text' => 'Proposal');
}
// Search customer order
Example #7
0
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid','int');

// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));

// Nombre de ligne pour choix de produit/service predefinis
$NBLINES = 4;

// Security check
if (! empty($user->societe_id)) $socid = $user->societe_id;
$result = restrictedArea($user, 'supplier_proposal', $id);

$object = new SupplierProposal($db);
$extrafields = new ExtraFields($db);

// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);

// Load object
if ($id > 0 || ! empty($ref)) {
	$ret = $object->fetch($id, $ref);
	if ($ret > 0)
		$ret = $object->fetch_thirdparty();
	if ($ret < 0)
		dol_print_error('', $object->error);
}

// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
Example #8
0
$originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
// PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
// Nombre de ligne pour choix de produit/service predefinis
$NBLINES = 4;
// Security check
if (!empty($user->societe_id)) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'supplier_proposal', $id);
$object = new SupplierProposal($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
    if ($ret > 0) {
        $ret = $object->fetch_thirdparty();
    }
    if ($ret < 0) {
        dol_print_error('', $object->error);
    }
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('supplier_proposalcard', 'globalcard'));
Example #9
0
 } elseif ($tmp == 'NotConfigured') {
     print $langs->trans($tmp);
 } else {
     print $tmp;
 }
 print '</td>' . "\n";
 print '<td align="center">';
 if ($conf->global->SUPPLIER_PROPOSAL_ADDON == "{$file}") {
     print img_picto($langs->trans("Activated"), 'switch_on');
 } else {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=' . $file . '">';
     print img_picto($langs->trans("Disabled"), 'switch_off');
     print '</a>';
 }
 print '</td>';
 $supplier_proposal = new SupplierProposal($db);
 $supplier_proposal->initAsSpecimen();
 // Info
 $htmltooltip = '';
 $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
 $nextval = $module->getNextValue($mysoc, $supplier_proposal);
 if ("{$nextval}" != $langs->trans("NotAvailable")) {
     // Keep " on nextval
     $htmltooltip .= '' . $langs->trans("NextValue") . ': ';
     if ($nextval) {
         if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
             $nextval = $langs->trans($nextval);
         }
         $htmltooltip .= $nextval . '<br>';
     } else {
         $htmltooltip .= $langs->trans($module->error) . '<br>';