Exemplo n.º 1
0
     print '<div class="error">' . $langs->trans($tmp) . '</div>';
 } elseif ($tmp == 'NotConfigured') {
     print $langs->trans($tmp);
 } else {
     print $tmp;
 }
 print '</td>' . "\n";
 print '<td align="center">';
 if ($conf->global->COMMANDE_SUPPLIER_ADDON_NUMBER == "{$file}") {
     print img_picto($langs->trans("Activated"), 'switch_on');
 } else {
     print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=' . $file . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
 }
 print '</td>';
 $commande = new CommandeFournisseur($db);
 $commande->initAsSpecimen();
 // Info
 $htmltooltip = '';
 $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
 $nextval = $module->getNextValue($mysoc, $commande);
 if ("{$nextval}" != $langs->trans("NotAvailable")) {
     // Keep " on nextval
     $htmltooltip .= '' . $langs->trans("NextValue") . ': ';
     if ($nextval) {
         if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
             $nextval = $langs->trans($nextval);
         }
         $htmltooltip .= $nextval . '<br>';
     } else {
         $htmltooltip .= $langs->trans($module->error) . '<br>';
     }
Exemplo n.º 2
0
    /**
     * testCommandeFournisseurBuild
      *
    * @return int
    */
    public function testCommandeFournisseurBuild()
    {
        global $conf,$user,$langs,$db;
        $conf=$this->savconf;
        $user=$this->savuser;
        $langs=$this->savlangs;
        $db=$this->savdb;

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

        // Muscadet
        $localobject->modelpdf='muscadet';
        $result=supplier_order_pdf_create($db, $localobject, $localobject->modelpdf, $langs);

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

        return 0;
        }
    /**
     */
    public function testCommandeFournisseurCreate()
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		$localobject=new CommandeFournisseur($this->savdb);
    	$localobject->initAsSpecimen();
    	$result=$localobject->create($user);

        print __METHOD__." result=".$result."\n";
    	$this->assertLessThan($result, 0);
    	return $result;
    }
Exemplo n.º 4
0
 /**
  * testCommandeFournisseurCreate
  *
  * @return	void
  */
 public function testCommandeFournisseurCreate()
 {
     global $conf, $user, $langs, $db;
     $conf = $this->savconf;
     $user = $this->savuser;
     $langs = $this->savlangs;
     $db = $this->savdb;
     // Set supplier and product to use
     $socid = 1;
     $societe = new Societe($db);
     $societe->fetch($socid);
     $product = new ProductFournisseur($db);
     $product->fetch(0, 'PIDRESS');
     if ($product->id <= 0) {
         print "\n" . __METHOD__ . " A product with ref PIDRESS must exists into database";
         die;
     }
     $quantity = 10;
     $ref_fourn = 'SUPPLIER_REF_PHPUNIT';
     $tva_tx = 19.6;
     // Create supplier price
     $result = $product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity);
     // This insert record with no value for price. Values are update later with update_buyprice
     $this->assertGreaterThanOrEqual(1, $result);
     $result = $product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0);
     $this->assertGreaterThanOrEqual(0, $result);
     // Create supplier order with a too low quantity
     $localobject = new CommandeFournisseur($db);
     $localobject->initAsSpecimen();
     $localobject->lines = array();
     // Overwrite lines of order
     $line = new CommandeFournisseurLigne($db);
     $line->desc = $langs->trans("Description") . " specimen line too low";
     $line->qty = 1;
     // So lower than $quantity
     $line->fk_product = $product->id;
     $line->ref_fourn = $ref_fourn;
     $localobject->lines[] = $line;
     $result = $localobject->create($user);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertEquals(-1, $result);
     // must be -1 because quantity is lower than minimum of supplier price
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "commande_fournisseur where ref=''";
     $db->query($sql);
     // Create supplier order
     $localobject2 = new CommandeFournisseur($db);
     $localobject2->initAsSpecimen();
     // This create 5 lines of first product found for socid 1
     $localobject2->lines = array();
     // Overwrite lines of order
     $line = new CommandeFournisseurLigne($db);
     $line->desc = $langs->trans("Description") . " specimen line ok";
     $line->qty = 10;
     // So enough quantity
     $line->fk_product = $product->id;
     $line->ref_fourn = $ref_fourn;
     $localobject2->lines[] = $line;
     $result = $localobject2->create($user);
     print __METHOD__ . " result=" . $result . "\n";
     $this->assertGreaterThanOrEqual(0, $result);
     return $result;
 }