Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7e28f16e

Von Holger Lindemann vor mehr als 12 Jahren hinzugefügt

  • ID 7e28f16efbb81644815ef06396b1d5c89c8bb5ec
  • Vorgänger b81f2b8f
  • Nachfolger 2d16e7a2

Diverse Verbesserungen u.a. Debugging

Unterschiede anzeigen:

peppershop/erplib.php
13 13

  
14 14
    var $db = false;
15 15
    var $error = false;
16
    var $pricegroup = 0;
16 17
    var $TAX = false;
17 18
    var $mkPart = true;
18 19
    var $divStd = false;
......
20 21
    var $doordnr = false;
21 22
    var $docustnr = false;
22 23
    var $lager = 1;
24
    var $warehouse_id = 0;
25
    var $transtype = 0;
23 26
    var $preordnr = '';
24 27
    var $precustnr = '';
25 28
    var $OEinsPart = false;
26 29
    var $INVnetto = true; //Rechnungen mit Nettopreisen
27 30
    var $SHOPincl = true; //Shoppreise sind Brutto
28 31

  
29
    function erp($db,$error,$divStd,$divVerm,$doordnr,$docustnr,$preordnr,$precustnr,$INVnetto,$SHOPincl,$OEinsPart,$lager) {
32
    function erp($db,$error,$divStd,$divVerm,$doordnr,$docustnr,$preordnr,$precustnr,$INVnetto,$SHOPincl,$OEinsPart,$lager,$pricegroup,$ERPusrID) {
30 33
        $this->db = $db;
34
        $this->pricegroup = $pricegroup;
35
        $this->employee_id = $ERPusrID;
31 36
        $this->error = $error;
32 37
        $this->divStd  = $divStd;
33 38
        $this->divVerm = $divVerm;
......
40 45
        $this->OEinsPart = ($OEinsPart == 1)?true:false;
41 46
        $this->lager = ($lager)?$lager:1;
42 47
        $this->getTax();
48
        if ( $lager > 1 ) {
49
            $sql  = "SELECT warehouse_id from bin where id = ".$this->lager;
50
            $rs = $this->db->getOne($sql);
51
            if ( $rs['warehouse_id'] > 0 ) {
52
		$this->warehouse_id = $rs['warehouse_id'];
53
                $sql = "SELECT id from transfer_type WHERE direction = 'in' and description = 'stock'";
54
                $rs = $this->db->getOne($sql);
55
                $this->transtype = $rs['id'];
56
            } else {
57
                $this->lager = 1;
58
            }
59
        }
43 60
    }
44 61

  
45 62
    function getTax() {
......
369 386
       $data = array(partnumber,description,longdescription,weight,sellprice,taxrate,partsgroup,unit)
370 387
       Rückgabe parts.id
371 388
       */
389
       $link = '<a href="../ic.pl?action=edit&id=%d" target="_blank">';
372 390
       if ($data['partnumber'] == '') {
373 391
           $this->error->write('erplib','Artikelnummer fehlt');
374 392
           return false;
......
408 426
       $sql .= "VALUES (:partnumber,:description,:sellprice,:weight,:notes,:shop,:unit,:partsgroup_id,";
409 427
       $sql .= ":image,:buchungsgruppen_id,1,1,1)";
410 428
       $rc = $this->db->insert($sql,$data);
429
       $data['parts_id'] = $this->chkPartnumber($data,false);
430
       if ( $this->pricegroup > 0 ) {
431
            $sql  = "INSERT INTO prices (parts_id,pricegroup_id,price) VALUES (:parts_id,:pricegroup,:shoppreis)";
432
            $data['pricegroup'] = $this->pricegroup;
433
            $rc = $this->db->insert($sql,$data);
434
       };
435
       if ( $data['onhand'] > 0 and $this->lager > 1) $this->insLager($data);
411 436
       $x =  $this->chkPartnumber($data,False);
412
       $this->error->out('Neuer Artikel: '.$data['partnumber'],true);
413
       $this->error->write('erplib','Artikel neu: '.$data['partnumber']);
437
       $this->error->write('erplib',$data['description'].' '.$data['partnumber']);
438
       $this->error->out(sprintf($link,$data['parts_id']).$data['description'].' '.$data['partnumber'].'</a>',true);
414 439
       return $x;
415 440
    }
441
    function insLager($data) {
442
        $rc = $this->db->Begin();
443
        $sql = "SELECT nextval(('id'::text)::regclass) as id from id";
444
        $rs = $this->db->getOne($sql);
445
        $sql  = "INSERT INTO inventory (warehouse_id,parts_id,shippingdate,employee_id,bin_id,qty,trans_id,trans_type_id,comment) ";
446
        $sql .= "VALUES (:wid,:parts_id,now(),:employee_id,:bid,:onhand,:next,:tt,'Shopübernahme')";
447
        $data['next'] = $rs['id'];
448
        $data['tt'] = $this->transtype;
449
        $data['bid'] = $this->lager;
450
        $data['wid'] = $this->warehouse_id;
451
        $data['employee_id'] = $this->employee_id;
452
        $rc = $this->db->insert($sql,$data);
453
        if ( $rc ) {
454
           $this->db->Commit();
455
        } else {
456
           $this->db->Rollback();
457
        }
458
    }
416 459
}
417 460
?>

Auch abrufbar als: Unified diff