Add category process Add Produk

A-35 ?

25. Add category process

?php include_once controllerCategoryCtrl.php; namaCate = _POST[nama]; if issetnamaCate { cont = new categoryCtrl; addCategory = cont-addCategorynamaCate; if addCategory == 1 { echo Kategori namaCate telah berhasil di buat; } else { echo Kategori .namaCate. sudah ada; } } else { echo {failed}; } To change this template, choose Tools | Templates and open the template in the editor. ?

26. Add Produk

DOCTYPE html PUBLIC -W3CDTD XHTML 1.0 StrictEN http:www.w3.orgTRxhtml1DTDxhtml1-strict.dtd ?php include_once controllerCategoryCtrl.php; include_once controllerprodukCtrl.php; include_once controlleroptionProdukCtrl.php; idProd = isset_GET[idProd] ? _GET[idProd] : ; controllerProd = new produkCtrl; controllerOPtion = new optionProdukCtrl; produkke; if idProd = { produkke = controllerProd-findProdukByIdidProd; } else { produkke = new vis_ProdUkModel; } include header.php; ? script type=textjavascript document.readyfunction { btnAdd.clickfunction { var num = .clonedInput.length; how many duplicatable input fields we currently have var newNum = new Numbernum + 1; the numeric ID of the new input field being added create the new element via clone, and manipulate its ID using newNum value var newElem = option + num.clone.attrid, option + newNum; manipulate the nameid values of the input inside the new element newElem.contents.findtd div input.attrid, linkgmbar + newNum.attrname, linkgmbar + newNum; newElem.contents.findtd input.eachfunction{ ifthis.attrid == linkImg+num{ this.attrid, linkImg + newNum.attrname, linkImg + newNum; } }; newElem.findtr.eachfunction{ ifthis.findtdinput.attrid == addHarga+num{ this.findtdinput.attrid, addHarga + newNum.attrname, addHarga + newNum; } ifthis.findtdinput.attrid == warna+num{ this.findtdinput.attrid, warna + newNum.attrname, warna + newNum; } this.findtd.eachfunction{ var id = this.findimg.attrid; ifid == loading+num{ this.findimg.attrid, loading + newNum; } A-36 ifid == preview+num{ this.findimg.attrid, preview + newNum; } }; }; var rr = newElem.childreninput.attrid, linkgmbar + newNum.attrid; var photo = this.val; newElem.childreninput [type=file].attrid, addHarga + newNum.attrname, addHarga + newNum; newElem.childrenimg.attrid, loading + newNum; newElem.childrenimg.attrid, preview + newNum; insert the new element after the last duplicatable input field option + num.afternewElem; enable the remove button btnDel.removeAttrdisabled; business rule: you can only add 5 names if newNum == 5 btnAdd.attrdisabled,disabled; }; btnDel.clickfunction { var num = .clonedInput.length; how many duplicatable input fields we currently have option + num.remove; remove the last element enable the add button btnAdd.removeAttrdisabled; if only one element remains, disable the remove button if num-1 == 1 btnDel.attrdisabled,disabled; }; btnDel.attrdisabled,disabled; input[type=file].livechange,function{ var num = this.attrid.replacelinkgmbar,; var photo = this.val; loading+num .ajaxStartfunction{ this.show; } .ajaxCompletefunction{ this.hide; }; .ajaxFileUpload { url:doajaxfileupload.php, secureuri:false, fileElementId:linkgmbar+num, dataType: json, data:{id_file:linkgmbar+num, id:id}, success: function data, status { iftypeofdata.error = undefined { ifdata.error = { alertdata.error }else { window.alertid=+test.attrid+ value=+test.attrvalue+ nomor=+num+; document.getElementByIdlinkImg+num.setAttributevalue, data.msg; document.getElementByIdpreview+num.setAttributesrc,..uploads+data.msg; preview+num.show; } } }, error: function data, status, e { alerte; preview+num.hide; } A-37 } }; }; script -- start content-outer -- div id=content-outer -- start content -- div id=content div id=page-headingh1Add producth1div table border=0 width=100 cellpadding=0 cellspacing=0 id=content-table tr th rowspan=3 class=sizedimg src=imagessharedside_shadowleft.jpg width=20 height=300 alt= th th class=topleftth td id=tbl-border-topnbsp;td th class=toprightth th rowspan=3 class=sizedimg src=imagessharedside_shadowright.jpg width=20 height=300 alt= th tr tr td id=tbl-border-lefttd td -- start content-table-inner -- div id=content-table-inner table border=0 width=100 cellpadding=0 cellspacing=0 tr valign=top td -- start step-holder -- div id=step-holder div class=step-no1div div class=step-dark-lefta href=Tambah Produkadiv div class=step-dark-rightnbsp;div div class=step-no-off2div div class=step-light-leftSelect related productsdiv div class=step-light-rightnbsp;div div class=step-no-off3div div class=step-light-leftPreviewdiv div class=step-light-roundnbsp;div div class=cleardiv div -- end step-holder -- -- start id-form -- form name=myform id=myform action=addProdukProcess.php method=POST onsubmit= table border=0 cellpadding=0 cellspacing=0 id=id-form tr th valign=topNama Produk:th tdinput type=text class=inp-form name=nameprod id=nameprod value=?php echo produkke-getNamAProdUk; ?td tdtd tr tr th valign=topHarga Produk:th tdinput type=text class=inp-form name=hargaprod id=hargaprod value=?php echo produkke-getHaRGa; ?td td td tr tr th valign=topCategory:th td select class=styledselect_form_1 name=kateprod id=kateprod ?php controller = new categoryCtrl; allCategory = controller-getAllCategory; foreach allCategory as value { if produkke-getCategory == value-getNamA { A-38 echo option value= . value-getNamA . SELECTED=TRUE . value-getNamA . option; } else { echo option value= . value-getNamA . . value-getNamA . option; } } ? select td tdtd tr tr th valign=topUkuran:th tdinput type=text class=inp-form name=ukuranprod value=?php echo produkke-getUkURan; ?td tdtd tr tr th valign=topKeterangan:th tdtextarea rows= cols= class=form-textarea name=ketprod id=ketprod value=?php echo produkke-getKeTeraNGan; ?textareatd tdtd tr tr thImage:th tdinput type=file class=file_1 name=fileToUpload id=fileToUpload onchange=ajaxFileUpload value=?php echo produkke-getImageLink; ?td td div class=bubble-leftdiv div class=bubble-innerJPEG, GIF 5MB max per imagediv div class=bubble-rightdiv td tdimg id=loading src=imagesloading.gif style=display:none;td tr tr td colspan=3img id=preview src=..uploads?php echo produkke- getImageLink; ? style=display:none; height=150 width=150td ?php if produkke-getImageLink = { ? script preview.show; script ?php } ? tr ?php if idProd = { optionsByID = controllerOPtion-getAllOptionsByPRodukidProd; num = 1; foreach optionsByID as value { ? tr thTambahan Warnath tdtd tr tr tdtd td div id=option1 class=clonedInput table tr thGambar warna:th td input type=file name=linkgmbar?php echo String num; ? id=linkgmbar?php echo String num; ? class=file_1 value=?php echo value-getImgLink; ? input type=hidden value=..uploads?php echo value- getImgLink; ? name=linkImg?php echo String num; ? id=linkImg?php echo String num; ? A-39 td tdimg id=loading?php echo String num; ? src=imagesloading.gif style=display:none;td tr tr td colspan=3img id=preview?php echo String num; ? src=..uploads?php echo value-getImgLink; ? style=display:none; height=150 width=150td script preview+?php echo String num; ?.show; script tr tr th Tambahan harga:th td input type=text name=addHarga?php echo String num; ? id=addHarga?php echo String num; ? class=inp-form value=?php echo value- getHargaAdded; ? td tr tr th Warna:th td input type=text name=warna?php echo String num; ? id=warna?php echo String num; ? class=inp-form value=?php echo value-getWarna; ? td tr table div td tr ?php num++; } } else { ? tr thTambahan Warnath tdtd tr tr tdtd td div id=option1 class=clonedInput table tr thGambar warna:th td input type=file name=linkgmbar1 id=linkgmbar1 class=file_1 input type=hidden value= name=linkImg1 id=linkImg1 td tdimg id=loading1 src=imagesloading.gif style=display:none;td tr tr td colspan=3img id=preview1 src= style=display:none; height=150 width=150td tr tr th Tambahan harga:th td input type=text name=addHarga1 id=addHarga1 class=inp- form td tr tr th Warna:th td A-40 input type=text name=warna1 id=warna1 class=inp- form td tr table div td tr ?php } ? tr td div table tr td input type=button id=btnAdd value=Tambah Option td td input type=button id=btnDel value=Hapus Option td tr table div td tdtd tr tr thnbsp;th td valign=top input type=hidden value=?php echo produkke-getImageLink; ? name=linkImg id=linkImg input type=hidden value=?php echo produkke-getIdProdUk; ? name=idprod id=idprod input type=submit value= name=submit class=form-submit input type=reset value= class=form-reset td tdtd tr table form div id=results div -- end id-form -- td td -- start related-activities -- -- end related-activities -- td tr tr tdimg src=imagessharedblank.gif width=695 height=1 alt=blank td tdtd tr table div class=cleardiv div -- end content-table-inner -- td td id=tbl-border-righttd tr tr th class=sized bottomleftth td id=tbl-border-bottomnbsp;td th class=sized bottomrightth tr table div class=clearnbsp;div div -- end content -- A-41 div class=clearnbsp;div div -- end content-outer -- ?php include footer.php; ?

27. Add Produk Process