// Build document if it not exists
 if (!$file || !is_readable($file)) {
     // Define output language
     $outputlangs = $langs;
     $newlang = '';
     if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) {
         $newlang = $_REQUEST['lang_id'];
     }
     if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
         $newlang = $object->client->default_lang;
     }
     if (!empty($newlang)) {
         $outputlangs = new Translate("", $conf);
         $outputlangs->setDefaultLang($newlang);
     }
     $result = propale_pdf_create($db, $object, GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
     if ($result <= 0) {
         dol_print_error($db, $result);
         exit;
     }
     $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/'));
     $file = $fileparams['fullname'];
 }
 print '<br>';
 print_titre($langs->trans('SendPropalByMail'));
 // Create form object
 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
 $formmail = new FormMail($db);
 $formmail->fromtype = 'user';
 $formmail->fromid = $user->id;
 $formmail->fromname = $user->getFullName($langs);
Esempio n. 2
0
    /**
     * testPropalBuild
     *
     * @return int
     */
    public function testPropalBuild()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

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

        // Einstein
        $localobject->modelpdf='azur';
        $result=propale_pdf_create($db, $localobject, $localobject->modelpdf, $langs);

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

        // Edison
        $localobject->modelpdf='jaune';
        $result=propale_pdf_create($db, $localobject, $localobject->modelpdf, $langs);

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

        return 0;
    }
Esempio n. 3
0
{
	$object->fetch($id);
	$object->fetch_thirdparty();
	$object->line_down(GETPOST('rowid'));

	// Define output language
	$outputlangs = $langs;
	$newlang='';
	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
	if (! empty($newlang))
	{
		$outputlangs = new Translate("",$conf);
		$outputlangs->setDefaultLang($newlang);
	}
	propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'));

	Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid'));
	exit;
}


/*
 * View
 */

llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');

$html = new Form($db);
$htmlother = new FormOther($db);
$formfile = new FormFile($db);
 /**
  *	Close the commercial proposal
  *
  *	@param      User	$user		Object user that close
  *	@param      int		$statut		Statut
  *	@param      string	$note		Comment
  *	@return     int         		<0 if KO, >0 if OK
  */
 function cloture($user, $statut, $note)
 {
     global $langs, $conf;
     $this->statut = $statut;
     $error = 0;
     $now = dol_now();
     $this->db->begin();
     $sql = "UPDATE " . MAIN_DB_PREFIX . "propal";
     $sql .= " SET fk_statut = " . $statut . ", note_private = '" . $this->db->escape($note) . "', date_cloture='" . $this->db->idate($now) . "', fk_user_cloture=" . $user->id;
     $sql .= " WHERE rowid = " . $this->id;
     $resql = $this->db->query($sql);
     if ($resql) {
         if ($statut == 2) {
             // The connected company is classified as a client
             $soc = new Societe($this->db);
             $soc->id = $this->socid;
             $result = $soc->set_as_client();
             if ($result < 0) {
                 $this->error = $this->db->error();
                 $this->db->rollback();
                 return -2;
             }
             if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
                 // Define output language
                 $outputlangs = $langs;
                 if (!empty($conf->global->MAIN_MULTILANGS)) {
                     $outputlangs = new Translate("", $conf);
                     $newlang = GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang;
                     $outputlangs->setDefaultLang($newlang);
                 }
                 //$ret=$object->fetch($id);    // Reload to get new records
                 propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
             }
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('PROPAL_CLOSE_SIGNED', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // Fin appel triggers
         } else {
             if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
                 // Define output language
                 $outputlangs = $langs;
                 if (!empty($conf->global->MAIN_MULTILANGS)) {
                     $outputlangs = new Translate("", $conf);
                     $newlang = GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang;
                     $outputlangs->setDefaultLang($newlang);
                 }
                 //$ret=$object->fetch($id);    // Reload to get new records
                 propale_pdf_create($this->db, $this, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
             }
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('PROPAL_CLOSE_REFUSED', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // Fin appel triggers
         }
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error();
         $this->db->rollback();
         return -1;
     }
 }