Exemple #1
0
    // Save modele used
    $facture=new FactureFournisseur($db);
    $facture->fetch($_REQUEST['facid']);
    if ($_REQUEST['model'])
    {
        $facture->setDocModel($user, $_REQUEST['model']);
    }

    $outputlangs = $langs;
    if (! empty($_REQUEST['lang_id']))
    {
        $outputlangs = new Translate("",$conf);
        $outputlangs->setDefaultLang($_REQUEST['lang_id']);
    }
    $result=supplier_invoice_pdf_create($db, $facture,$facture->modelpdf,$outputlangs);
    if ($result	<= 0)
    {
        dol_print_error($db,$result);
        exit;
    }
    else
    {
        Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facture->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
        exit;
    }
}

// Delete file in doc form
if ($action=='remove_file')
{
 // 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 = supplier_invoice_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->fournisseur->facture->dir_output . '/' . get_exdir($object->id, 2) . $ref, preg_quote($ref, '/'));
     $file = $fileparams['fullname'];
 }
 print '<br>';
 print_titre($langs->trans('SendBillByMail'));
 // Cree l'objet formulaire mail
 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);
Exemple #3
0
    /**
    * testFactureBuild
    *
    * @return int
    */
    public function testFactureFournisseurBuild()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

        $conf->fournisseur->facture->dir_output.='/temp';
        $localobject=new FactureFournisseur($this->savdb);
        $localobject->initAsSpecimen();

        // Canelle
        $localobject->modelpdf='canelle';
        $result=supplier_invoice_pdf_create($db, $localobject, $localobject->modelpdf, $langs);

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

        return 0;
    }