function readsalebackdunshu($year, $month, $memid) { $db = new DB_test(); $dberp = new DB_erp2(); $query = "select * from tb_organmem where fd_organmem_id = '{$memid}'"; $db->query($query); $db->next_record(); $cusid = $db->f(fd_organmem_cusid); $month = $month + 0; $year = $year + 0; $query = "select \n sum(fd_sebk_alldunshu) as allquantity,\n fd_sebk_cusid\n from tb_saleback \n left join tb_salelist on fd_sebk_salelistid = fd_selt_id\n where year(fd_selt_date) = '{$year}' and month(fd_sebk_date) = '{$month}' and fd_sebk_state = 1\n and fd_sebk_iskickback = 0 and fd_sebk_organid = 1 and fd_sebk_cusid = '{$cusid}'\n group by fd_sebk_cusid\n "; $dberp->query($query); $dberp->next_record(); $dunshu = $dberp->f(allquantity); return $dunshu; }
function order_creat_kslist($listid) { $db = new DB_test(); $db2 = new DB_test(); $dberp = new DB_erp2(); //读取客诉申请 $query = "select * from web_kesu \n\t left join tb_produre on fd_produre_id = fd_ks_commid \n\t left join tb_productlevel on fd_productlevel_id = fd_produre_level \n\t left join tb_kgweight on fd_kgweight_id = fd_produre_kgweight \n\t left join tb_guige on fd_guige_id = fd_produre_spec \n\t left join web_orderdetail on fd_ks_orderdtid = fd_orderdetail_id \n\t left join web_order on fd_order_id = fd_ks_orderid\n\t where fd_ks_id = '{$listid}'"; $db->query($query); if ($db->nf()) { $db->next_record(); $commid = $db->f(fd_ks_commid); $thquantity = $db->f(fd_ks_tuinum); $printsize = $db->f(fd_ks_yincc); $fqsl = $db->f(fd_ks_fenqienum); $shsl = $db->f(fd_ks_sunhao); $printsl = $db->f(fd_ks_yinnum); $memo = $db->f(fd_ks_canzhi); $ksmoney = $db->f(fd_ks_money); $ksyy = $db->f(fd_ks_cause); $zlms = $db->f(fd_ks_ksmemo); $memo = $db->f(fd_ks_memo); $czmoney = $db->f(fd_ks_canzhi); $commname = $db->f(fd_produre_name); $level = $db->f(fd_productlevel_name); $kz = $db->f(fd_kgweight_name); $gg = $db->f(fd_guige_name); $orderid = $db->f(fd_ks_orderid); $price = $db->f(fd_orderdetail_price); $quantity = $db->f(fd_orderdetail_quantity); $sdcrid = $db->f(fd_order_sdcrid); if ($cause == 1) { //印刷不良 $ksyy = "1@@@"; } else { if ($cause == 2) { //纸张表面异常 $ksyy = "6@@@"; } else { if ($cause == 3) { //纸张克数不够 $ksyy = "4@@@"; } else { if ($cause == 4) { //打烂胶布 $ksyy = "5@@@"; } } } } $money = $quantity * $price; $kstype = 2; if ($sdcrid == 1) { $mscid = 1; //广州市明盛物流有限公司 } else { if ($sdcrid == 2) { $mscid = 4; //上海粤琳珠物流有限公司 } else { if ($sdcrid == 3) { $mscid = 13; //廊坊市明盛纸业有限公司 } else { if ($sdcrid == 4) { $mscid = 9; } else { if ($sdcrid == 5) { $mscid = 11; } } } } } $query = "select * from tb_mscompany where fd_msc_id = '{$mscid}'"; $dberp->query($query); if ($dberp->nf()) { $dberp->next_record(); $msclinkman = $dberp->f(fd_msc_phone); } $query = "select * from tb_salelist where fd_selt_weborderid = '{$orderid}'"; $dberp->query($query); if ($dberp->nf()) { $dberp->next_record(); $xsno = $dberp->f(fd_selt_no); $xsdate = $dberp->f(fd_selt_date); $cusid = $dberp->f(fd_selt_cusid); } $listno = listnumber_update(); $query = "insert into tb_kssq(\n\t \t fd_kssq_no , fd_kssq_date , fd_kssq_organid ,\n\t \t fd_kssq_mscid , fd_kssq_msclinkman , fd_kssq_cusid ,\n\t \t fd_kssq_commid , fd_kssq_commname , fd_kssq_level ,\n\t \t fd_kssq_kz , fd_kssq_gg , fd_kssq_xsno ,\n\t \t fd_kssq_xsdate , fd_kssq_price , fd_kssq_quantity ,\n\t \t fd_kssq_money , fd_kssq_thquantity , fd_kssq_ksmoney ,\n\t \t fd_kssq_czmoney , fd_kssq_ksyy , fd_kssq_zlms ,\n\t \t fd_kssq_memo , fd_kssq_kstype , fd_kssq_printsize , \n\t \t fd_kssq_fqsl , fd_kssq_printsl , fd_kssq_shsl ,\n\t \t fd_kssq_state , fd_kssq_webksid \n\t \t )values(\n\t \t '{$listno}' , now() , '1' ,\n\t \t '{$mscid}' , '{$msclinkman}' , '{$cusid}' ,\n\t \t '{$commid}' , '{$commname}' , '{$level}' , \n\t \t '{$kz}' , '{$gg}' , '{$xsno}' ,\n\t \t '{$xsdate}' , '{$price}' ,'{$quantity}' ,\n\t \t '{$money}' , '{$thquantity}' , '{$ksmoney}' ,\n\t \t '{$czmoney}' , '{$ksyy}' , '{$zlms}' ,\n\t \t '{$memo}' , '{$kstype}' , '{$printsize}' , \n\t \t '{$fqsl}' , '{$printsl}' , '{$shsl}' ,\n\t \t '2' , '{$listid}'\n\t \t )"; $dberp->query($query); } }
function order_creat_fplist($listid) { $db = new DB_test(); $db2 = new DB_test(); $dberp = new DB_erp2(); //读取发票申请 $query = "select * from web_invoicesq \n\t left join tb_organmem on fd_organmem_id = fd_ivcsq_memberid\n\t where fd_ivcsq_id = '{$listid}'"; $db->query($query); if ($db->nf()) { $db->next_record(); $iecrid = $db->f(fd_ivcsq_fpcusid); $iecrno = $db->f(fd_ivcsq_fpcusno); $iecrname = $db->f(fd_ivcsq_fpcusname); $orderid = $db->f(fd_ivcsq_orderid); $fptype = $db->f(fd_ivcsq_fptype); $money = $db->f(fd_ivcsq_money); $memo = $db->f(fd_ivcsq_memo); $fpusename = $db->f(fd_organmem_comnpany); $fpuseid = $db->f(fd_ivcsq_memberid); if ($invoicetype == "普通发票") { $invoicetype = 1; } else { $invoicetype = 0; } $s_orderid = implode(",", explode("@@@", $orderid)); $query = "select * from web_order \n where fd_order_id in ({$s_orderid}) "; $db->query($query); if ($db->nf()) { $db->next_record(); $sdcrid = $db->f(fd_order_sdcrid); if ($sdcrid == 1) { $mscompanyid = 1; //广州市明盛物流有限公司 } else { if ($sdcrid == 2) { $mscompanyid = 4; //上海粤琳珠物流有限公司 } else { if ($sdcrid == 3) { $mscompanyid = 13; //廊坊市明盛纸业有限公司 } else { if ($sdcrid == 4) { $mscompanyid = 9; } else { if ($sdcrid == 5) { $mscompanyid = 11; } } } } } } $issue = date("Y", mktime()) . date("m", mktime()); $listno = listnumber_update(); $query = "insert into tb_invoiceapply(\n\t fd_ieay_listno , fd_ieay_iecrid , fd_ieay_iecrno ,\n\t fd_ieay_iecrname , fd_ieay_sporganid , fd_ieay_date , \n\t fd_ieay_mscompanyid , fd_ieay_issue , fd_ieay_staname ,\n\t fd_ieay_invoicetype , fd_ieay_sdcrid , fd_ieay_cporganid , \n\t fd_ieay_xjmoney , fd_ieay_yhmoney , fd_ieay_spsdcrid ,\n\t fd_ieay_memo , fd_ieay_dziecrid , fd_ieay_sqinvoicetype ,\n\t fd_ieay_sqmscid , fd_ieay_sqyhmoney , fd_ieay_sqxjmoney ,\n\t fd_ieay_websqid , fd_ieay_fpuseid , fd_ieay_fpusename\n\t )values(\n\t '{$listno}' , '{$iecrid}' , '{$iecrno}' ,\n\t '{$iecrname}' , '1' , now() ,\n\t '{$mscompanyid}' , '{$issue}' , '网站' ,\n\t '{$invoicetype}' , '{$sdcrid}' , '1' , \n\t '0' , '{$money}' , '{$sdcrid}' ,\n\t '{$memo}' , '{$iecrid}' , '{$invoicetype}' ,\n\t '{$mscompanyid}' , '0' , '{$money}' ,\n\t '{$listid}' , '{$fpuseid}' , '{$fpusename}'\n\t )"; $dberp->query($query); } }