コード例 #1
0
 /**
  * Validate an order
  * 
  * @param   int $id             Order ID
  * @param   int $idwarehouse    Warehouse ID
  * 
  * @url GET     order/{id}/validate
  * @url POST    order/{id}/validate
  *  
  * @return  array
  * 
  */
 function validOrder($id, $idwarehouse = 0)
 {
     if (!DolibarrApiAccess::$user->rights->commande->creer) {
         throw new RestException(401);
     }
     $result = $this->commande->fetch($id);
     if (!$result) {
         throw new RestException(404, 'Order not found');
     }
     if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
         throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login);
     }
     if (!$this->commande->valid(DolibarrApiAccess::$user, $idwarehouse)) {
         throw new RestException(500, 'Error when validate order');
     }
     return array('success' => array('code' => 200, 'message' => 'Order validated'));
 }
コード例 #2
0
ファイル: newpayment.php プロジェクト: remyyounes/dolibarr
	print '<tr><td class="CTableRow'.($var?'1':'2').'">'.$langs->trans("YourEMail");
	print ' ('.$langs->trans("ToComplete").')';
	print '</td><td class="CTableRow'.($var?'1':'2').'"><input class="flat" type="text" name="email" size="48" value="'.GETPOST("email").'"></td></tr>'."\n";
}


// Payment on customer order
if (GETPOST("source") == 'order')
{
	$found=true;
	$langs->load("orders");

	require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");

	$order=new Commande($db);
	$result=$order->fetch('',$_REQUEST["ref"]);
	if ($result < 0)
	{
		$mesg=$order->error;
		$error++;
	}
	else
	{
		$result=$order->fetch_thirdparty($order->socid);
	}

	$amount=$order->total_ttc;
    if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
    $amount=price2num($amount);

	$fulltag='IR='.$order->ref.'.TPID='.$order->client->id.'.TP='.strtr($order->client->nom,"-"," ");
コード例 #3
0
ファイル: newpayment.php プロジェクト: ADDAdev/Dolibarr
    $var = !$var;
    print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("PaymentCode");
    print '</td><td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . $fulltag . '</b>';
    print '<input type="hidden" name="tag" value="' . $tag . '">';
    print '<input type="hidden" name="fulltag" value="' . $fulltag . '">';
    print '</td></tr>' . "\n";
    // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
    // as they don't exists (buyer is unknown, tag is free).
}
// Payment on customer order
if (GETPOST("source") == 'order' && $valid) {
    $found = true;
    $langs->load("orders");
    require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
    $order = new Commande($db);
    $result = $order->fetch('', $ref);
    if ($result < 0) {
        $mesg = $order->error;
        $error++;
    } else {
        $result = $order->fetch_thirdparty($order->socid);
    }
    $amount = $order->total_ttc;
    if (GETPOST("amount", 'int')) {
        $amount = GETPOST("amount", 'int');
    }
    $amount = price2num($amount);
    $fulltag = 'ORD=' . $order->ref . '.CUS=' . $order->thirdparty->id;
    //$fulltag.='.NAM='.strtr($order->thirdparty->name,"-"," ");
    if (!empty($TAG)) {
        $tag = $TAG;
コード例 #4
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $mysoc->logo;
     if ($mysoc->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     // Add origin linked objects
     // TODO extend to other objects
     $object->fetchObjectLinked('', '', $object->id, 'delivery');
     if (!empty($object->linkedObjects)) {
         $outputlangs->load('orders');
         foreach ($object->linkedObjects as $elementtype => $objects) {
             $object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
             foreach ($object->linkedObjects as $elementtype => $objects) {
                 $num = count($objects);
                 for ($i = 0; $i < $num; $i++) {
                     $order = new Commande($this->db);
                     $result = $order->fetch($objects[$i]->id);
                     if ($result >= 0) {
                         $posy += 5;
                         $pdf->SetXY($posx, $posy);
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $text = $order->ref;
                         if ($order->ref_client) {
                             $text .= ' (' . $order->ref_client . ')';
                         }
                         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
                     }
                 }
             }
         }
     }
     if ($showaddress) {
         // Emetteur
         $posy = 42;
         $hautcadre = 40;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($this->marge_gauche, $posy - 5);
         $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom") . ":");
         $pdf->SetXY($this->marge_gauche, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 3);
         // Nom emetteur
         $pdf->SetTextColor(0, 0, 60);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($this->marge_gauche + 2, $posy + 9);
         $pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY(102, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // Cadre client destinataire
         $pdf->Rect(100, $posy, 100, $hautcadre);
         // If SHIPPING contact defined on invoice, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         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 ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->nom;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
         // Show customer/recipient
         $pdf->SetXY(102, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(106, 4, $carac_client_name, 0, 'L');
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY(102, $posy + 8);
         $pdf->MultiCell(86, 4, $carac_client, 0, 'L');
     }
 }
コード例 #5
0
function _genInfoEtiquette(&$db, &$PDOdb, &$TPrintTicket)
{
    global $conf;
    $TInfoEtiquette = array();
    if (empty($TPrintTicket)) {
        return $TInfoEtiquette;
    }
    dol_include_once('/commande/class/commande.class.php');
    $assetOf = new TAssetOF();
    $cmd = new Commande($db);
    $product = new Product($db);
    $pos = 1;
    $cpt = 0;
    foreach ($TPrintTicket as $fk_assetOf => $qty) {
        if ($qty <= 0) {
            continue;
        }
        $load = $assetOf->load($PDOdb, $fk_assetOf);
        if ($load === true) {
            $cmd->fetch($assetOf->fk_commande);
            foreach ($assetOf->TAssetOFLine as &$assetOfLine) {
                if ($assetOfLine->type == 'TO_MAKE' && $product->fetch($assetOfLine->fk_product) > 0) {
                    for ($i = 0; $i < $qty; $i++) {
                        $cpt++;
                        if ($cpt % 2 == 0) {
                            $div = 'pair';
                        } else {
                            $div = 'impair';
                        }
                        $TInfoEtiquette[] = array('numOf' => $assetOf->numero, 'float' => $div, 'refCmd' => $cmd->ref, 'refCliCmd' => $cmd->ref_client, 'refProd' => $product->ref, 'qty_to_print' => $qty, 'qty_to_make' => $assetOfLine->qty, 'label' => wordwrap(preg_replace('/\\s\\s+/', ' ', $product->label), 20, $conf->global->DEFAULT_ETIQUETTES == 2 ? "\n" : "</br>"), 'pos' => ceil($pos / 8));
                        //var_dump($TInfoEtiquette);exit;
                        $pos++;
                        //var_dump($TInfoEtiquette);
                    }
                }
            }
        }
    }
    //exit;
    return $TInfoEtiquette;
}
コード例 #6
0
ファイル: CommandeTest.php プロジェクト: Samara94/dolibarr
 /**
  * testCommandeDelete
  *
  * @param   int $id         Id of order
  * @return  void
  *
  * @depends testCommandeOther
  * The depends says test is run only if previous is ok
  */
 public function testCommandeDelete($id)
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Commande($this->savdb);
     $result = $localobject->fetch($id);
     $result = $localobject->delete($user);
     print __METHOD__ . " id=" . $id . " result=" . $result . "\n";
     $this->assertLessThan($result, 0);
     return $result;
 }
コード例 #7
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
  *  @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->commande->dir_output) {
         // If $object is id instead of object
         if (!is_object($object)) {
             $id = $object;
             $object = new Commande($this->db);
             $result = $object->fetch($id);
             if ($result < 0) {
                 dol_print_error($this->db, $object->error);
                 return -1;
             }
         }
         $dir = $conf->commande->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->commande->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 = 'ORDER_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->commande->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('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);
             $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;
 }
コード例 #8
0
/**
 *  Supprime l'image de previsualitation, pour le cas de regeneration de commande
 *  @param	    db  		data base object
 *  @param	    commandeid	id de la commande a effacer
 *  @param      commanderef reference de la commande si besoin
 */
function commande_delete_preview($db, $commandeid, $commanderef='')
{
	global $langs,$conf;
    require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");

	if (!$commanderef)
	{
		$com = new Commande($db,"",$commandeid);
		$com->fetch($commandeid);
		$commanderef = $com->ref;
	}

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

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

				if ( file_exists( $preview ) && is_writable( $preview ) )
				{
					if ( ! dol_delete_file($preview,1) )
					{
						$this->error=$langs->trans("ErrorFailedToOpenFile",$preview);
						return 0;
					}
				}
			}
		}
	}

	return 1;
}
コード例 #9
0
/**
 *    	Show html area with actions done
 *
 * 		@param	Conf		$conf		Object conf
 * 		@param	Translate	$langs		Object langs
 * 		@param	DoliDB		$db			Object db
 * 		@param	Adherent|Societe		$object		Object third party or member
 * 		@param	Contact		$objcon		Object contact
 *      @param  int			$noprint    Return string but does not output it
 *      @return	mixed					Return html part or void if noprint is 1
 * TODO change function to be able to list event linked to an object.
 */
function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0)
{
    global $bc, $user, $conf;
    // Check parameters
    if (!is_object($object)) {
        dol_print_error('', 'BadParameter');
    }
    $out = '';
    $histo = array();
    $numaction = 0;
    $now = dol_now('tzuser');
    if (!empty($conf->agenda->enabled)) {
        // Recherche histo sur actioncomm
        $sql = "SELECT a.id, a.label,";
        $sql .= " a.datep as dp,";
        $sql .= " a.datep2 as dp2,";
        $sql .= " a.note, a.percent,";
        $sql .= " a.fk_element, a.elementtype,";
        $sql .= " a.fk_user_author, a.fk_contact,";
        $sql .= " c.code as acode, c.libelle,";
        $sql .= " u.login, u.rowid as user_id";
        if (get_class($object) == 'Societe') {
            $sql .= ", sp.lastname, sp.firstname";
        }
        if (get_class($object) == 'Adherent') {
            $sql .= ", m.lastname, m.firstname";
        }
        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a";
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_actioncomm as c ON a.fk_action = c.id";
        if (get_class($object) == 'Societe') {
            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
        }
        if (get_class($object) == 'Adherent') {
            $sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
        }
        $sql .= " WHERE u.rowid = a.fk_user_author";
        $sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")";
        if (get_class($object) == 'Societe' && $object->id) {
            $sql .= " AND a.fk_soc = " . $object->id;
        }
        if (get_class($object) == 'Adherent') {
            $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
        }
        if (get_class($object) == 'Adherent' && $object->id) {
            $sql .= " AND a.fk_element = " . $object->id;
        }
        if (is_object($objcon) && $objcon->id) {
            $sql .= " AND a.fk_contact = " . $objcon->id;
        }
        $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))";
        $sql .= " ORDER BY a.datep DESC, a.id DESC";
        dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
        $resql = $db->query($sql);
        if ($resql) {
            $i = 0;
            $num = $db->num_rows($resql);
            $var = true;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'dateend' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype);
                $numaction++;
                $i++;
            }
        } else {
            dol_print_error($db);
        }
    }
    if (!empty($conf->mailing->enabled) && !empty($objcon->email)) {
        $langs->load("mails");
        // Recherche histo sur mailing
        $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,";
        $sql .= " 'AC_EMAILING' as acode,";
        $sql .= " u.rowid as user_id, u.login";
        // User that valid action
        $sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u";
        $sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'";
        // Search is done on email.
        $sql .= " AND mc.statut = 1";
        $sql .= " AND u.rowid = m.fk_user_valid";
        $sql .= " AND mc.fk_mailing=m.rowid";
        $sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
        dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
        $resql = $db->query($sql);
        if ($resql) {
            $i = 0;
            $num = $db->num_rows($resql);
            $var = true;
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $histo[$numaction] = array('type' => 'mailing', 'id' => $obj->id, 'datestart' => $db->jdate($obj->da), 'dateend' => $db->jdate($obj->da), 'note' => $obj->note, 'percent' => $obj->percentage, 'acode' => $obj->acode, 'userid' => $obj->user_id, 'login' => $obj->login);
                $numaction++;
                $i++;
            }
            $db->free($resql);
        } else {
            dol_print_error($db);
        }
    }
    if (!empty($conf->agenda->enabled) || !empty($conf->mailing->enabled) && !empty($objcon->email)) {
        require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
        require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
        require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
        require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
        $actionstatic = new ActionComm($db);
        $userstatic = new User($db);
        $contactstatic = new Contact($db);
        // TODO uniformize
        $propalstatic = new Propal($db);
        $orderstatic = new Commande($db);
        $facturestatic = new Facture($db);
        $out .= "\n";
        $out .= '<table class="noborder" width="100%">';
        $out .= '<tr class="liste_titre">';
        if ($conf->global->AGENDA_USE_EVENT_TYPE) {
            $out .= '<td colspan="3">';
        } else {
            $out .= '<td colspan="2">';
        }
        if (get_class($object) == 'Societe') {
            $out .= '<a href="' . DOL_URL_ROOT . '/comm/action/listactions.php?socid=' . $object->id . '&amp;status=done">';
        }
        $out .= $langs->trans("ActionsDoneShort");
        if (get_class($object) == 'Societe') {
            $out .= '</a>';
        }
        $out .= '</td>';
        if ($conf->global->AGENDA_USE_EVENT_TYPE) {
            $out .= '<td>';
            $out .= $langs->trans("Type");
            $out .= '</td>';
            $out .= '<td colspan="4" align="right">';
        } else {
            $out .= '<td colspan="5" align="right">';
        }
        $out .= '</td>';
        $out .= '</tr>';
        foreach ($histo as $key => $value) {
            $var = !$var;
            $out .= "<tr " . $bc[$var] . ">";
            $actionstatic->fetch($histo[$key]['id']);
            // Champ date
            $out .= '<td width="120" class="nowrap">';
            $out .= dol_print_date($histo[$key]['datestart'], 'dayhour');
            if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) {
                $tmpa = dol_getdate($histo[$key]['datestart'], true);
                $tmpb = dol_getdate($histo[$key]['dateend'], true);
                if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
                    $out .= '-' . dol_print_date($histo[$key]['dateend'], 'hour');
                } else {
                    $out .= '-' . dol_print_date($histo[$key]['dateend'], 'dayhour');
                }
            }
            $out .= "</td>\n";
            // Picto
            $out .= '<td width="16">&nbsp;</td>';
            // Action
            $out .= '<td>';
            if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
                $actionstatic->type_code = $histo[$key]['acode'];
                $transcode = $langs->trans("Action" . $histo[$key]['acode']);
                $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['libelle'];
                //$actionstatic->libelle=$libelle;
                $actionstatic->libelle = $histo[$key]['note'];
                $actionstatic->id = $histo[$key]['id'];
                $out .= $actionstatic->getNomUrl(1, 120);
            }
            if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
                $out .= '<a href="' . DOL_URL_ROOT . '/comm/mailing/card.php?id=' . $histo[$key]['id'] . '">' . img_object($langs->trans("ShowEMailing"), "email") . ' ';
                $transcode = $langs->trans("Action" . $histo[$key]['acode']);
                $libelle = $transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing';
                $out .= dol_trunc($libelle, 120);
            }
            $out .= '</td>';
            if ($conf->global->AGENDA_USE_EVENT_TYPE) {
                $out .= '<td>';
                $out .= $actionstatic->type;
                $out .= '</td>';
            }
            // Title of event
            //$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
            // Objet lie
            // TODO uniformize
            $out .= '<td>';
            //var_dump($histo[$key]['elementtype']);
            if (isset($histo[$key]['elementtype'])) {
                if ($histo[$key]['elementtype'] == 'propal' && !empty($conf->propal->enabled)) {
                    //$propalstatic->ref=$langs->trans("ProposalShort");
                    //$propalstatic->id=$histo[$key]['fk_element'];
                    if ($propalstatic->fetch($histo[$key]['fk_element']) > 0) {
                        $propalstatic->type = $histo[$key]['ftype'];
                        $out .= $propalstatic->getNomUrl(1);
                    } else {
                        $out .= $langs->trans("ProposalDeleted");
                    }
                } elseif (($histo[$key]['elementtype'] == 'order' || $histo[$key]['elementtype'] == 'commande') && !empty($conf->commande->enabled)) {
                    //$orderstatic->ref=$langs->trans("Order");
                    //$orderstatic->id=$histo[$key]['fk_element'];
                    if ($orderstatic->fetch($histo[$key]['fk_element']) > 0) {
                        $orderstatic->type = $histo[$key]['ftype'];
                        $out .= $orderstatic->getNomUrl(1);
                    } else {
                        $out .= $langs->trans("OrderDeleted");
                    }
                } elseif (($histo[$key]['elementtype'] == 'invoice' || $histo[$key]['elementtype'] == 'facture') && !empty($conf->facture->enabled)) {
                    //$facturestatic->ref=$langs->trans("Invoice");
                    //$facturestatic->id=$histo[$key]['fk_element'];
                    if ($facturestatic->fetch($histo[$key]['fk_element']) > 0) {
                        $facturestatic->type = $histo[$key]['ftype'];
                        $out .= $facturestatic->getNomUrl(1, 'compta');
                    } else {
                        $out .= $langs->trans("InvoiceDeleted");
                    }
                } else {
                    $out .= '&nbsp;';
                }
            } else {
                $out .= '&nbsp;';
            }
            $out .= '</td>';
            // Contact pour cette action
            if (!empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
                $contactstatic->lastname = $histo[$key]['lastname'];
                $contactstatic->firstname = $histo[$key]['firstname'];
                $contactstatic->id = $histo[$key]['contact_id'];
                $out .= '<td width="120">' . $contactstatic->getNomUrl(1, '', 10) . '</td>';
            } else {
                $out .= '<td>&nbsp;</td>';
            }
            // Auteur
            $out .= '<td class="nowrap" width="80">';
            //$userstatic->id=$histo[$key]['userid'];
            //$userstatic->login=$histo[$key]['login'];
            //$out.=$userstatic->getLoginUrl(1);
            $userstatic->fetch($histo[$key]['userid']);
            $out .= $userstatic->getNomUrl(1);
            $out .= '</td>';
            // Statut
            $out .= '<td class="nowrap" width="20">' . $actionstatic->LibStatut($histo[$key]['percent'], 3) . '</td>';
            $out .= "</tr>\n";
            $i++;
        }
        $out .= "</table>\n";
        $out .= "<br>\n";
    }
    if ($noprint) {
        return $out;
    } else {
        print $out;
    }
}
コード例 #10
0
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/order.lib.php';
if (!$user->rights->commande->lire) {
    accessforbidden();
}
$langs->load("orders");
$langs->load("sendings");
// Security check
$socid = 0;
$comid = GETPOST("id", 'int');
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $comid, '');
/*
 * View
 */
llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$commande = new Commande($db);
$commande->fetch($comid);
$commande->info($comid);
$soc = new Societe($db);
$soc->fetch($commande->socid);
$head = commande_prepare_head($commande);
dol_fiche_head($head, 'info', $langs->trans("CustomerOrder"), 0, 'order');
print '<table width="100%"><tr><td>';
dol_print_object_info($commande);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();
コード例 #11
0
<?php 
if (is_object($mc)) {
    $conf->entity = $entity;
    $user->fetch($userid);
}
$sql = "SELECT fk_soc, fk_paycash, fk_modepaycash, fk_paybank, fk_modepaybank, fk_warehouse FROM " . MAIN_DB_PREFIX . "pos_cash where rowid={$terminal}";
$resql = $db->query($sql);
$rowterminal = $db->fetch_array($resql);
if ($placenoid != "") {
    $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "commande where ref='Place-{$placenoid}' and entity={$entity}";
    $resql = $db->query($sql);
    $row = $db->fetch_array($resql);
    $place = $row[0];
}
$object = new Commande($db);
$res = $object->fetch($place);
$user = new User($db);
$user->fetch($userid);
if (is_object($mc)) {
    $facture = new Facture($db);
} else {
    $facture = new Facturesim($db);
}
if ($pay == "cash") {
    $object->mode_reglement_id = $rowterminal[2];
} else {
    $object->mode_reglement_id = $rowterminal[4];
}
$facture->createFromOrder($object);
$user->getrights();
if ($conf->stock->enabled) {
コード例 #12
0
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) {
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
$object = new Commande($db);
/*
 * Actions
 */
if ($object->fetch($id)) {
    $object->fetch_thirdparty();
    $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
}
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
    if ($object->fetch($id, $ref)) {
        $object->fetch_thirdparty();
        $upload_dir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($object->ref);
        $head = commande_prepare_head($object);
        dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order');
コード例 #13
0
ファイル: server_order.php プロジェクト: ADDAdev/Dolibarr
/**
 * Update an order
 *
 * @param	array		$authentication		Array of authentication information
 * @param	array		$order				Order info
 * @return	array							Array result
 */
function updateOrder($authentication, $order)
{
    global $db, $conf, $langs;
    $now = dol_now();
    dol_syslog("Function: updateOrder login="******"Order id or ref or ref_ext is mandatory.";
    }
    if (!$error) {
        $objectfound = false;
        include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
        $object = new Commande($db);
        $result = $object->fetch($order['id'], empty($order['id']) ? $order['ref'] : '', empty($order['id']) && empty($order['ref']) ? $order['ref_ext'] : '');
        if (!empty($object->id)) {
            $objectfound = true;
            $db->begin();
            if (isset($order['status'])) {
                if ($order['status'] == -1) {
                    $result = $object->cancel($fuser);
                }
                if ($order['status'] == 1) {
                    $result = $object->valid($fuser);
                }
                if ($order['status'] == 0) {
                    $result = $object->set_reopen($fuser);
                }
                if ($order['status'] == 3) {
                    $result = $object->cloture($fuser);
                }
            }
            if (isset($order['billed'])) {
                if ($order['billed']) {
                    $result = $object->classifyBilled($fuser);
                }
                if (!$order['billed']) {
                    $result = $object->classifyBilled($fuser);
                }
            }
            //Retreive all extrafield for object
            // fetch optionals attributes and labels
            $extrafields = new ExtraFields($db);
            $extralabels = $extrafields->fetch_name_optionals_label('commande', true);
            foreach ($extrafields->attribute_label as $key => $label) {
                $key = 'options_' . $key;
                if (isset($order[$key])) {
                    $result = $object->setValueFrom($key, $order[$key], 'commande_extrafields');
                }
            }
            if ($result <= 0) {
                $error++;
            }
        }
        if (!$error && $objectfound) {
            $db->commit();
            $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $object->id);
        } elseif ($objectfound) {
            $db->rollback();
            $error++;
            $errorcode = 'KO';
            $errorlabel = $object->error;
        } else {
            $error++;
            $errorcode = 'NOT_FOUND';
            $errorlabel = 'Order id=' . $order['id'] . ' ref=' . $order['ref'] . ' ref_ext=' . $order['ref_ext'] . ' cannot be found';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
コード例 #14
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			&$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $langs, $conf, $mysoc;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     $outputlangs->load("companies");
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $posy = $this->marge_haute;
     $pdf->SetXY($this->marge_gauche, $posy);
     if ($conf->global->MAIN_INFO_SOCIETE_NOM) {
         $pdf->SetTextColor(0, 0, 200);
         $pdf->SetFont('', 'B', $default_font_size + 2);
         $pdf->MultiCell(76, 4, $outputlangs->convToOutputCharset(MAIN_INFO_SOCIETE_NOM), 0, 'L');
     }
     // Sender properties
     $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
     $pdf->SetFont('', '', $default_font_size - 1);
     $pdf->SetXY($this->marge_gauche, $posy + 4);
     $pdf->MultiCell(80, 3, $carac_emetteur, 0, 'L');
     /*
      * Adresse Client
      */
     // If SHIPPING contact defined on invoice, we use it
     $usecontact = false;
     $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
     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 ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) {
             $socname = $object->contact->socname;
         } else {
             $socname = $object->client->nom;
         }
         $carac_client_name = $outputlangs->convToOutputCharset($socname);
     } else {
         $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom);
     }
     $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $object->contact, $usecontact, 'target');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY(102, 42);
     $pdf->MultiCell(96, 5, $carac_client_name, 0, 'L');
     $pdf->SetFont('', 'B', $default_font_size);
     $pdf->SetXY(102, 47);
     $pdf->MultiCell(96, 5, $carac_client, 0, 'L');
     $pdf->Rect(100, 40, 100, 40);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 1);
     $pdf->SetXY($posx, 86);
     $pdf->MultiCell(100, 2, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery ? $object->date_delivery : $date->valid, "day", false, $outputlangs, true), 0, 'R');
     $pdf->SetXY($posx, 92);
     $pdf->MultiCell(100, 2, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), 0, 'R');
     if ($object->client->code_client) {
         $posy += 7;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetFont('', 'B', $default_font_size - 1);
     // Add origin linked objects
     // TODO extend to other objects
     $object->fetchObjectLinked('', '', $object->id, 'delivery');
     if (!empty($object->linkedObjects)) {
         $outputlangs->load('orders');
         foreach ($object->linkedObjects as $elementtype => $objects) {
             $object->fetchObjectLinked('', '', $objects[0]->id, $objects[0]->element);
             foreach ($object->linkedObjects as $elementtype => $objects) {
                 $num = count($objects);
                 for ($i = 0; $i < $num; $i++) {
                     $order = new Commande($this->db);
                     $result = $order->fetch($objects[$i]->id);
                     if ($result >= 0) {
                         $posy += 5;
                         $pdf->SetXY($posx, $posy);
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $text = $order->ref;
                         if ($order->ref_client) {
                             $text .= ' (' . $order->ref_client . ')';
                         }
                         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), '', 'R');
                     }
                 }
             }
         }
     }
 }
コード例 #15
0
 /**
  *  Function to build pdf onto disk
  *
  *  @param		Object		$object				Object to generate
  *  @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=OK, 0=KO
  */
 function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 {
     global $user, $langs, $conf, $mysoc, $hookmanager;
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
     if (!empty($conf->global->MAIN_USE_FPDF)) {
         $outputlangs->charset_output = 'ISO-8859-1';
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     if ($conf->expedition->dir_output) {
         $object->fetch_thirdparty();
         // Definition of $dir and $file
         if ($object->specimen) {
             $dir = $conf->expedition->dir_output . "/receipt";
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $objectref = dol_sanitizeFileName($object->ref);
             $dir = $conf->expedition->dir_output . "/receipt/" . $objectref;
             $file = $dir . "/" . $objectref . ".pdf";
         }
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return 0;
             }
         }
         if (file_exists($dir)) {
             // Add pdfgeneration hook
             if (!is_object($hookmanager)) {
                 include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
                 $hookmanager = new HookManager($this->db);
             }
             $hookmanager->initHooks(array('pdfgeneration'));
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
             global $action;
             $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action);
             // Note that $action and $object may have been modified by some hooks
             $nblines = count($object->lines);
             // Create pdf instance
             $pdf = pdf_getInstance($this->format);
             $default_font_size = pdf_getPDFFontSize($outputlangs);
             // Must be after pdf_getInstance
             $heightforinfotot = 30;
             // Height reserved to output the info and total part
             $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5;
             // Height reserved to output the free text on last page
             $heightforfooter = $this->marge_basse + 8;
             // Height reserved to output the footer (value include bottom margin)
             $pdf->SetAutoPageBreak(1, 0);
             if (class_exists('TCPDF')) {
                 $pdf->setPrintHeader(false);
                 $pdf->setPrintFooter(false);
             }
             $pdf->SetFont(pdf_getPDFFont($outputlangs));
             // Set path to the background PDF File
             if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
                 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
                 $tplidx = $pdf->importPage(1);
             }
             // We get the shipment that is the origin of delivery receipt
             $expedition = new Expedition($this->db);
             $result = $expedition->fetch($object->origin_id);
             // Now we get the order that is origin of shipment
             $commande = new Commande($this->db);
             if ($expedition->origin == 'commande') {
                 $commande->fetch($expedition->origin_id);
             }
             $object->commande = $commande;
             // We set order of shipment onto delivery.
             $object->commande->loadExpeditions();
             $pdf->Open();
             $pagenb = 0;
             $pdf->SetDrawColor(128, 128, 128);
             $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
             $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("DeliveryOrder"));
             if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
                 $pdf->SetCompression(false);
             }
             $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
             // Left, Top, Right
             /*
             // Positionne $this->atleastonediscount si on a au moins une remise
             for ($i = 0 ; $i < $nblines ; $i++)
             {
              	if ($object->lines[$i]->remise_percent)
              	{
              		$this->atleastonediscount++;
              	}
             }
              				if (empty($this->atleastonediscount))
             {
             	$this->posxpicture+=($this->postotalht - $this->posxdiscount);
             	$this->posxtva+=($this->postotalht - $this->posxdiscount);
             	$this->posxup+=($this->postotalht - $this->posxdiscount);
             	$this->posxqty+=($this->postotalht - $this->posxdiscount);
             	$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
             	//$this->postotalht;
             }
             */
             // New page
             $pdf->AddPage();
             if (!empty($tplidx)) {
                 $pdf->useTemplate($tplidx);
             }
             $pagenb++;
             $this->_pagehead($pdf, $object, 1, $outputlangs);
             $pdf->SetFont('', '', $default_font_size - 1);
             $pdf->MultiCell(0, 3, '');
             // Set interline to 3
             $pdf->SetTextColor(0, 0, 0);
             $tab_top = 90;
             $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10;
             $tab_height = 130;
             $tab_height_newpage = 150;
             // Affiche notes
             if (!empty($object->note_public)) {
                 $tab_top = 88;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
                 $nexY = $pdf->GetY();
                 $height_note = $nexY - $tab_top;
                 // Rect prend une longueur en 3eme param
                 $pdf->SetDrawColor(192, 192, 192);
                 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
                 $tab_height = $tab_height - $height_note;
                 $tab_top = $nexY + 6;
             } else {
                 $height_note = 0;
             }
             $iniY = $tab_top + 7;
             $curY = $tab_top + 7;
             $nexY = $tab_top + 7;
             // Loop on each lines
             for ($i = 0; $i < $nblines; $i++) {
                 $curY = $nexY;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Into loop to work with multipage
                 $pdf->SetTextColor(0, 0, 0);
                 $pdf->setTopMargin($tab_top_newpage);
                 $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
                 // The only function to edit the bottom margin of current page to set it.
                 $pageposbefore = $pdf->getPage();
                 // Description of product line
                 $curX = $this->posxdesc - 1;
                 $showpricebeforepagebreak = 1;
                 $pdf->startTransaction();
                 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc);
                 $pageposafter = $pdf->getPage();
                 if ($pageposafter > $pageposbefore) {
                     $pdf->rollbackTransaction(true);
                     $pageposafter = $pageposbefore;
                     //print $pageposafter.'-'.$pageposbefore;exit;
                     $pdf->setPageOrientation('', 1, $heightforfooter);
                     // The only function to edit the bottom margin of current page to set it.
                     pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc);
                     $posyafter = $pdf->GetY();
                     if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) {
                         if ($i == $nblines - 1) {
                             $pdf->AddPage('', '', true);
                             if (!empty($tplidx)) {
                                 $pdf->useTemplate($tplidx);
                             }
                             if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                                 $this->_pagehead($pdf, $object, 0, $outputlangs);
                             }
                             $pdf->setPage($pageposafter + 1);
                         }
                     } else {
                         // We found a page break
                         $showpricebeforepagebreak = 0;
                     }
                 } else {
                     $pdf->commitTransaction();
                 }
                 $nexY = $pdf->GetY();
                 $pageposafter = $pdf->getPage();
                 $pdf->setPage($pageposbefore);
                 $pdf->setTopMargin($this->marge_haute);
                 $pdf->setPageOrientation('', 1, 0);
                 // The only function to edit the bottom margin of current page to set it.
                 // We suppose that a too long description is moved completely on next page
                 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 /*
                 // TVA
                 $pdf->SetXY($this->posxcomm, $curY);
                 $pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R');
                 
                 // Prix unitaire HT avant remise
                 $pdf->SetXY($this->posxup, $curY);
                 $pdf->MultiCell(20, 4, price($object->lines[$i]->subprice), 0, 'R', 0);
                 */
                 // Quantity
                 //$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
                 $pdf->SetXY($this->posxqty, $curY);
                 $pdf->MultiCell($this->posxremainingqty - $this->posxqty, 3, $object->lines[$i]->qty_shipped, 0, 'R');
                 // Remaining to ship
                 $pdf->SetXY($this->posxremainingqty, $curY);
                 $qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line];
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R');
                 /*
                 // Remise sur ligne
                 $pdf->SetXY($this->posxdiscount, $curY);
                 if ($object->lines[$i]->remise_percent)
                 {
                 $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R');
                 }
                 
                 // Total HT ligne
                 $pdf->SetXY($this->postotalht, $curY);
                 $total = price($object->lines[$i]->price * $object->lines[$i]->qty);
                 $pdf->MultiCell(23, 3, $total, 0, 'R', 0);
                 
                 // Collecte des totaux par valeur de tva
                 // dans le tableau tva["taux"]=total_tva
                 $tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty;
                 if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
                 $this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne;
                 */
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblines - 1) {
                     $pdf->setPage($pageposafter);
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$pdf->SetDrawColor(190,190,200);
                     $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
                     $pdf->SetLineStyle(array('dash' => 0));
                 }
                 $nexY += 2;
                 // Passe espace entre les lignes
                 // Detect if some page were added automatically and output _tableau for past pages
                 while ($pagenb < $pageposafter) {
                     $pdf->setPage($pagenb);
                     if ($pagenb == 1) {
                         $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs, 1);
                     $pagenb++;
                     $pdf->setPage($pagenb);
                     $pdf->setPageOrientation('', 1, 0);
                     // The only function to edit the bottom margin of current page to set it.
                     if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                         $this->_pagehead($pdf, $object, 0, $outputlangs);
                     }
                 }
                 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
                     if ($pagenb == 1) {
                         $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs, 1);
                     // New page
                     $pdf->AddPage();
                     if (!empty($tplidx)) {
                         $pdf->useTemplate($tplidx);
                     }
                     $pagenb++;
                     if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
                         $this->_pagehead($pdf, $object, 0, $outputlangs);
                     }
                 }
             }
             // Show square
             if ($pagenb == 1) {
                 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
             } else {
                 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
             }
             // Affiche zone infos
             $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
             // Pied de page
             $this->_pagefoot($pdf, $object, $outputlangs);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $pdf->AliasNbPages();
             }
             // Check product remaining to be delivered
             // TODO doit etre modifie
             //$waitingDelivery = $object->getRemainingDelivered();
             /*
             				$waitingDelivery='';
             
             				if (is_array($waitingDelivery) & !empty($waitingDelivery))
             				{
             					$pdf->AddPage();
             
             					$this->_pagehead($pdf, $object, 1, $outputlangs);
             					$pdf-> SetY(90);
             
             					$w=array(40,100,50);
             					$header=array($outputlangs->transnoentities('Reference'),
             								  $outputlangs->transnoentities('Label'),
             								  $outputlangs->transnoentities('Qty')
             								  );
             
                 				// Header
                 				$num = count($header);
                					for($i = 0; $i < $num; $i++)
                					{
                						$pdf->Cell($w[$i],7,$header[$i],1,0,'C');
                					}
             
             			    	$pdf->Ln();
             
             			    	// Data
             					foreach($waitingDelivery as $value)
             					{
             						$pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L');
             						$pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L');
             						$pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R');
             
             						if ($pdf->GetY() > 250)
             						{
             							$this->_pagefoot($pdf,$object,$outputlangs,1);
             
             							$pdf->AddPage('P', 'A4');
             
             							$pdf->SetFont('','', $default_font_size - 1);
             							$this->_pagehead($pdf, $object, 0, $outputlangs);
             
             							$pdf-> SetY(40);
             
             							$num = count($header);
             							for($i = 0; $i < $num; $i++)
             							{
             								$pdf->Cell($w[$i],7,$header[$i],1,0,'C');
             							}
             
             							$pdf->Ln();
             						}
             					}
             
             					$this->_pagefoot($pdf,$object,$outputlangs);
             
             					if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
             				}*/
             $pdf->Close();
             $pdf->Output($file, 'F');
             // Add pdfgeneration hook
             if (!is_object($hookmanager)) {
                 include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
                 $hookmanager = new HookManager($this->db);
             }
             $hookmanager->initHooks(array('pdfgeneration'));
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
             global $action;
             $reshook = $hookmanager->executeHooks('afterPDFCreation', $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));
             }
             return 1;
             // pas d'erreur
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     }
     $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
     return 0;
 }
コード例 #16
0
function enteteexpedition(&$expedition)
{
    global $langs, $db, $user, $hookmanager, $conf;
    $form = new Form($db);
    $soc = new Societe($db);
    $soc->fetch($expedition->socid);
    if (!empty($expedition->origin)) {
        $typeobject = $expedition->origin;
        $origin = $expedition->origin;
        $expedition->fetch_origin();
    }
    print '<table class="border" width="100%">';
    $linkback = '<a href="' . DOL_URL_ROOT . '/expedition/liste.php">' . $langs->trans("BackToList") . '</a>';
    // Ref
    print '<tr><td width="20%">' . $langs->trans("Ref") . '</td>';
    print '<td colspan="3">';
    print $form->showrefnav($expedition, 'ref', $linkback, 1, 'ref', 'ref');
    print '</td></tr>';
    // Customer
    print '<tr><td width="20%">' . $langs->trans("Customer") . '</td>';
    print '<td colspan="3">' . $soc->getNomUrl(1) . '</td>';
    print "</tr>";
    // Linked documents
    if ($typeobject == 'commande' && $expedition->{$typeobject}->id && !empty($conf->commande->enabled)) {
        print '<tr><td>';
        $objectsrc = new Commande($db);
        $objectsrc->fetch($expedition->{$typeobject}->id);
        print $langs->trans("RefOrder") . '</td>';
        print '<td colspan="3">';
        print $objectsrc->getNomUrl(1, 'commande');
        print "</td>\n";
        print '</tr>';
    }
    if ($typeobject == 'propal' && $expedition->{$typeobject}->id && !empty($conf->propal->enabled)) {
        print '<tr><td>';
        $objectsrc = new Propal($db);
        $objectsrc->fetch($expedition->{$typeobject}->id);
        print $langs->trans("RefProposal") . '</td>';
        print '<td colspan="3">';
        print $objectsrc->getNomUrl(1, 'expedition');
        print "</td>\n";
        print '</tr>';
    }
    // Ref customer
    print '<tr><td>' . $langs->trans("RefCustomer") . '</td>';
    print '<td colspan="3">' . $expedition->ref_customer . "</a></td>\n";
    print '</tr>';
    // Date creation
    print '<tr><td>' . $langs->trans("DateCreation") . '</td>';
    print '<td colspan="3">' . dol_print_date($expedition->date_creation, "day") . "</td>\n";
    print '</tr>';
    // Delivery date planed
    print '<tr><td height="10">';
    print '<table class="nobordernopadding" width="100%"><tr><td>';
    print $langs->trans('DateDeliveryPlanned');
    print '</td>';
    print '</tr></table>';
    print '</td><td colspan="2">';
    print $expedition->date_delivery ? dol_print_date($expedition->date_delivery, 'dayhourtext') : '&nbsp;';
    print '</td>';
    print '</tr>';
    // Status
    print '<tr><td>' . $langs->trans("Status") . '</td>';
    print '<td colspan="3">' . $expedition->getLibStatut(4) . "</td>\n";
    print '</tr>';
    // Sending method
    print '<tr><td height="10">';
    print '<table class="nobordernopadding" width="100%"><tr><td>';
    print $langs->trans('SendingMethod');
    print '</td>';
    print '</tr></table>';
    print '</td><td colspan="2">';
    if ($expedition->shipping_method_id > 0) {
        // Get code using getLabelFromKey
        $code = $langs->getLabelFromKey($db, $expedition->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
        print $langs->trans("SendingMethod" . strtoupper($code));
    }
    print '</td>';
    print '</tr>';
    print "</table>\n";
}
コード例 #17
0
ファイル: fiche.php プロジェクト: remyyounes/dolibarr
	if ($result > 0)
	{
		Header("Location: ".DOL_URL_ROOT."/comm/propal.php?id=".$propal->id);
		return;
	}

	$mesg = $langs->trans("ErrorUnknown").": $result";
}

/*
 * Ajout du produit dans une commande
 */
if ($action == 'addincommande')
{
	$commande = new Commande($db);
	$result=$commande->fetch($_POST["commandeid"]);
	if ($result <= 0)
	{
		dol_print_error($db,$commande->error);
		exit;
	}

	$soc = new Societe($db);
	$result=$soc->fetch($commande->socid);
	if ($result <= 0)
	{
		dol_print_error($db,$soc->error);
		exit;
	}

	$prod = new Product($db);
コード例 #18
0
    $commande->fetch($id);
    $result = $commande->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
    if ($result < 0) {
        dol_print_error($db, $commande->error);
    }
}
/*
 * View
 */
$form = new Form($db);
$formfile = new FormFile($db);
$formproduct = new FormProduct($db);
llxHeader('', $langs->trans('OrderCard'), '');
if ($id > 0 || !empty($ref)) {
    $commande = new Commande($db);
    if ($commande->fetch($id, $ref) > 0) {
        $commande->loadExpeditions(1);
        $product_static = new Product($db);
        $soc = new Societe($db);
        $soc->fetch($commande->socid);
        $author = new User($db);
        $author->fetch($commande->user_author_id);
        $head = commande_prepare_head($commande);
        dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), 0, 'order');
        /*
         * Confirmation de la validation
         */
        if ($action == 'cloture') {
            print $form->formconfirm($_SERVER['PHP_SELF'] . "?id=" . $id, $langs->trans("CloseShipment"), $langs->trans("ConfirmCloseShipment"), "confirm_cloture");
        }
        // Onglet commande
コード例 #19
0
ファイル: card.php プロジェクト: Albertopf/prueba
     }
 }
 // Add product into object
 if ($object->id > 0 && $action == 'addin') {
     $thirpdartyid = 0;
     if (GETPOST('propalid') > 0) {
         $propal = new Propal($db);
         $result = $propal->fetch(GETPOST('propalid'));
         if ($result <= 0) {
             dol_print_error($db, $propal->error);
             exit;
         }
         $thirpdartyid = $propal->socid;
     } elseif (GETPOST('commandeid') > 0) {
         $commande = new Commande($db);
         $result = $commande->fetch(GETPOST('commandeid'));
         if ($result <= 0) {
             dol_print_error($db, $commande->error);
             exit;
         }
         $thirpdartyid = $commande->socid;
     } elseif (GETPOST('factureid') > 0) {
         $facture = new Facture($db);
         $result = $facture->fetch(GETPOST('factureid'));
         if ($result <= 0) {
             dol_print_error($db, $facture->error);
             exit;
         }
         $thirpdartyid = $facture->socid;
     }
     if ($thirpdartyid > 0) {
コード例 #20
0
ファイル: contact.php プロジェクト: Samara94/dolibarr
$langs->load("sendings");
$langs->load("companies");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id, '');
$object = new Commande($db);
/*
 * Ajout d'un nouveau contact
 */
if ($action == 'addcontact' && $user->rights->commande->creer) {
    $result = $object->fetch($id);
    if ($result > 0 && $id > 0) {
        $contactid = GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int');
        $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
    }
    if ($result >= 0) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
        exit;
    } else {
        if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
            $langs->load("errors");
            setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
        } else {
            setEventMessages($object->error, $object->errors, 'errors');
        }
    }
コード例 #21
0
 /**
  *  Update a supplier order from a customer order
  *
  *  @param  User	$user           User that create
  *  @param  int		$idc			Id of supplier order to update
  *  @param	int		$comclientid	Id of customer order to use as template
  *	@return	int						<0 if KO, >0 if OK
  */
 function updateFromCommandeClient($user, $idc, $comclientid)
 {
     $comclient = new Commande($this->db);
     $comclient->fetch($comclientid);
     $this->id = $idc;
     $this->lines = array();
     $num = count($comclient->lines);
     for ($i = 0; $i < $num; $i++) {
         $prod = new Product($this->db);
         if ($prod->fetch($comclient->lines[$i]->fk_product) > 0) {
             $libelle = $prod->libelle;
             $ref = $prod->ref;
         }
         $sql = "INSERT INTO " . MAIN_DB_PREFIX . "commande_fournisseurdet";
         $sql .= " (fk_commande,label,description,fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)";
         $sql .= " VALUES (" . $idc . ", '" . $this->db->escape($libelle) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'";
         $sql .= "," . $comclient->lines[$i]->fk_product . ",'" . price2num($comclient->lines[$i]->price) . "'";
         $sql .= ", '" . $comclient->lines[$i]->qty . "', " . $comclient->lines[$i]->tva_tx . ", " . $comclient->lines[$i]->localtax1_tx . ", " . $comclient->lines[$i]->localtax2_tx . ", " . $comclient->lines[$i]->remise_percent;
         $sql .= ", '" . price2num($comclient->lines[$i]->subprice) . "','0','" . $ref . "');";
         if ($this->db->query($sql)) {
             $this->update_price();
         }
     }
     return 1;
 }
コード例 #22
0
// PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
// Security check
if (!empty($user->societe_id)) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id);
$object = new Commande($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);
    $ret = $object->fetch_thirdparty();
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ordercard'));
$permissionnote = $user->rights->commande->creer;
// Used by the include of actions_setnotes.inc.php
/*
 * Actions
 */
$parameters = array('socid' => $socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php';
// Must be include, not includ_once
// Action clone object
コード例 #23
0
ファイル: note.php プロジェクト: remyyounes/dolibarr
$langs->load("companies");
$langs->load("bills");
$langs->load("orders");

// Security check
$socid=0;
$comid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'commande',$comid,'');


$id = $_GET['id'];
$ref= $_GET['ref'];
$commande = new Commande($db);
if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
{
	dol_print_error($db);
}


/*
 * Actions
 */

if ($_POST["action"] == 'update' && $user->rights->commande->creer)
{
	$db->begin();

	$resPrivateNote=$commande->update_note($_POST["note"]);
	$resPublicNote=$commande->update_note_public($_POST["note_public"]);
コード例 #24
0
ファイル: apercu.php プロジェクト: TAASA/Dolibarr-ERP-3.8.1
$langs->load('compta');
// Security check
$socid = 0;
$id = GETPOST('id', 'int');
$ref = GETPOST("ref");
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'commande', $id, '');
/*
 * View Mode
 */
llxHeader('', $langs->trans('Order'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
if ($id > 0 || !empty($ref)) {
    $object = new Commande($db);
    if ($object->fetch($id, $ref) > 0) {
        $soc = new Societe($db);
        $soc->fetch($object->socid);
        $head = commande_prepare_head($object);
        dol_fiche_head($head, 'preview', $langs->trans("CustomerOrder"), 0, 'order');
        print '<table class="border" width="100%">';
        // Ref
        print '<tr><td width="25%">' . $langs->trans("Ref") . "</td>";
        print '<td colspan="5">' . $object->ref . '</td></tr>';
        // Ref cde client
        print '<tr><td>' . $langs->trans('RefCustomer') . '</td>';
        print '<td colspan="5">' . $object->ref_client . '</td>';
        print '</tr>';
        // Client
        print '<tr><td>' . $langs->trans("Customer") . '</td>';
        print '<td colspan="5">' . $soc->getNomUrl(1) . '</td>';
コード例 #25
0
ファイル: commande.class.php プロジェクト: ripasch/dolibarr
 /**
  *		Load an object from its id and create a new one in database
  *		@param      fromid     		Id of object to clone
  *		@param		invertdetail	Reverse sign of amounts for lines
  *		@param		socid			Id of thirdparty
  * 	 	@return		int				New id of clone
  */
 function createFromClone($fromid, $invertdetail = 0, $socid = 0)
 {
     global $conf, $user, $langs;
     $error = 0;
     $object = new Commande($this->db);
     // Instantiate hooks of thirdparty module
     if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) {
         $object->callHooks('ordercard');
     }
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $objFrom = $object;
     // Change socid if needed
     if (!empty($socid) && $socid != $object->socid) {
         $objsoc = new Societe($this->db);
         if ($objsoc->fetch($socid) > 0) {
             $object->socid = $objsoc->id;
             $object->cond_reglement_id = !empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0;
             $object->mode_reglement_id = !empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0;
             $object->fk_project = '';
             $object->fk_delivery_address = '';
         }
         // TODO Change product price if multi-prices
     }
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     $object->user_author_id = $user->id;
     $object->user_valid = '';
     $object->date_creation = '';
     $object->date_validation = '';
     $object->ref_client = '';
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
         // Hook of thirdparty module
         if (!empty($object->hooks)) {
             foreach ($object->hooks as $hook) {
                 if (!empty($hook['modules'])) {
                     foreach ($hook['modules'] as $module) {
                         if (method_exists($module, 'createfrom')) {
                             $result = $module->createfrom($objFrom, $result, $object->element);
                             if ($result < 0) {
                                 $error++;
                             }
                         }
                     }
                 }
             }
         }
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
         $interface = new Interfaces($this->db);
         $result = $interface->run_triggers('ORDER_CLONE', $object, $user, $langs, $conf);
         if ($result < 0) {
             $error++;
             $this->errors = $interface->errors;
         }
         // Fin appel triggers
     }
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
コード例 #26
0
ファイル: document.php プロジェクト: remyyounes/dolibarr
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";


$object = new Commande($db);


/*
 * Actions
 */

// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
	if ($object->fetch($id))
    {
        $object->fetch_thirdparty();

	    $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);

		if (create_exdir($upload_dir) >= 0)
		{
			$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']);
			if (is_numeric($resupload) && $resupload > 0)
			{
				$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
			}
			else
			{
				$langs->load("errors");
コード例 #27
0
ファイル: card.php プロジェクト: NoisyBoy86/Dolibarr_test
 $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
 $formmail->withtopic = $outputlangs->trans('SendShippingRef', '__SHIPPINGREF__');
 $formmail->withfile = 2;
 $formmail->withbody = 1;
 $formmail->withdeliveryreceipt = 1;
 $formmail->withcancel = 1;
 // Tableau des substitutions
 $formmail->substit['__SHIPPINGREF__'] = $object->ref;
 $formmail->substit['__SIGNATURE__'] = $user->signature;
 $formmail->substit['__PERSONALIZED__'] = '';
 $formmail->substit['__CONTACTCIVNAME__'] = '';
 //Find the good contact adress
 //Find the good contact adress
 if ($typeobject == 'commande' && $object->{$typeobject}->id && !empty($conf->commande->enabled)) {
     $objectsrc = new Commande($db);
     $objectsrc->fetch($object->{$typeobject}->id);
 }
 if ($typeobject == 'propal' && $object->{$typeobject}->id && !empty($conf->propal->enabled)) {
     $objectsrc = new Propal($db);
     $objectsrc->fetch($object->{$typeobject}->id);
 }
 $custcontact = '';
 $contactarr = array();
 $contactarr = $objectsrc->liste_contact(-1, 'external');
 if (is_array($contactarr) && count($contactarr) > 0) {
     foreach ($contactarr as $contact) {
         if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) {
             require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
             $contactstatic = new Contact($db);
             $contactstatic->fetch($contact['id']);
             $custcontact = $contactstatic->getFullName($langs, 1);
コード例 #28
0
 print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
 $html->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id');
 print '</td></tr>';
 // Project
 if (!empty($conf->projet->enabled)) {
     $formproject = new FormProjets($db);
     $langs->load('projects');
     print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
     $formproject->select_projects($soc->id, $projectid, 'projectid');
     print '</td></tr>';
 }
 include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
 $objectsrc = new Commande($db);
 $listoforders = array();
 foreach ($selected as $sel) {
     $result = $objectsrc->fetch($sel);
     if ($result > 0) {
         $listoforders[] = $objectsrc->ref;
     }
 }
 // Other attributes
 $parameters = array('objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="3"');
 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
 // Note that $action and $object may have been modified by hook
 // Modele PDF
 print '<tr><td>' . $langs->trans('Model') . '</td>';
 print '<td>';
 include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php';
 $liste = ModelePDFFactures::liste_modeles($db);
 print $html->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF);
 print "</td></tr>";
コード例 #29
0
ファイル: fiche.php プロジェクト: remyyounes/dolibarr
			// Ref
			print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
			print '<td colspan="3">'.$delivery->ref.'</td></tr>';

			// Client
			print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
			print '<td align="3">'.$soc->getNomUrl(1).'</td>';
			print "</tr>";

			// Document origine
			if ($typeobject == 'commande' && $expedition->origin_id && $conf->commande->enabled)
			{
				print '<tr><td>'.$langs->trans("RefOrder").'</td>';
				$order=new Commande($db);
				$order->fetch($expedition->origin_id);
				print '<td colspan="3">';
				print $order->getNomUrl(1,'commande');
				print "</td>\n";
				print '</tr>';
			}
			if ($typeobject == 'propal' && $expedition->origin_id && $conf->propal->enabled)
			{
				$propal=new Propal($db);
				$propal->fetch($expedition->origin_id);
				print '<tr><td>'.$langs->trans("RefProposal").'</td>';
				print '<td colspan="3">';
				print $propal->getNomUrl(1,'expedition');
				print "</td>\n";
				print '</tr>';
			}
コード例 #30
0
 /**
  *  testFetchThirdParty
  *
  *  @return void
  */
 public function testFetchThirdParty()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     $localobject = new Commande($this->savdb);
     $localobject->fetch(1);
     $result = $localobject->fetch_thirdparty();
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertLessThanOrEqual($result, 0);
     return $result;
 }