PK

ADDRLIN : /home/anibklip/aaravpest.in/
FLL :
Current File : /home/anibklip/aaravpest.in/create_invoice_prd.php

<?php
include "templatic/head.php";
include "templatic/header.php";
?>
<div class="box">
	<div style="padding:0px 10px;">
		<?php
		if (isset($_POST['sbmt_btn'])) {
			//Invoice
			$clntid = $_POST['clntid'];
			$ajtname = $_POST['ajtname'];
			$date = $_POST['issuedate'];
			$certid=$_POST[certid];
			//$amt = $_POST['amount'];
			$stax = $_POST['srtax'];
			$grtotal = $_POST['finalone'];

			for($j=1;$j<=3;$j++){
				if($_POST['particular'.$j])
					$particular.= $_POST['particular'.$j]."~~";
				if($_POST['hsncode'.$j])
					$hsncode.= $_POST['hsncode'.$j]."~~";
				if($_POST['qty'.$j])
					$qty.= $_POST['qty'.$j]."~~";
				if($_POST['rate'.$j]){
					$rate.= $_POST['rate'.$j]."~~";
					$amt+=$_POST['rate'.$j]*$_POST['qty'.$j];
				}
			}
			//print_r($_POST);
			$particular=substr($particular,0,-2);
			$hsncode=substr($hsncode,0,-2);
			$qty=substr($qty,0,-2);
			$rate=substr($rate,0,-2);
			if($_GET[invid]){
				$sqlinvoice="update invoices set
					trans_mode='$_POST[trans_mode]',
					vehicle='$_POST[vehicle]',
					supply_dt='$_POST[supply_dt]',
					supply_place='$_POST[supply_place]',
					clnid='$clntid', 
					dtd='$date', 
					amount='$amt', 
					servicetax='$stax',
					grandtotal='$grtotal',
					particular='$particular',
					hsncode='$hsncode',
					qty1='$qty',
					rate='$rate',
					travel_exp='$_POST[travel_exp]',
					other_exp='$_POST[other_exp]',
					gst_combine='$_POST[gst_combine]'
					where invid='$_GET[invid]'
				";
				$msg="Invoice Updated successfully.";
			}else{
				$sqlinvoice="INSERT INTO invoices set
					user_id='$_SESSION[user_id]',
					inv_type=2,
					trans_mode='$_POST[trans_mode]',
					vehicle='$_POST[vehicle]',
					supply_dt='$_POST[supply_dt]',
					supply_place='$_POST[supply_place]',
					clnid='$clntid', 
					dtd='$date', 
					amount='$amt', 
					servicetax='$stax',
					grandtotal='$grtotal',
					particular='$particular',
					hsncode='$hsncode',
					qty1='$qty',
					rate='$rate',
					travel_exp='$_POST[travel_exp]',
					other_exp='$_POST[other_exp]',
					gst_combine='$_POST[gst_combine]'
				";
				$msg="Invoice Created successfully.";
			}
			//echo "<pre>$sqlinvoice </pre>";
			mysql_query($sqlinvoice) or die(mysql_error().' - Error in creating Invoice');

			$arr=explode(",",$certid);
			foreach($arr as $k=>$v){
				$q="update certificates set inv_done=1 where certificateno='$v' ";
				//echo "$q <br>";
				mysql_query($q) or die(mysql_error());
				//$invno=mysql_insert_id();
			}
			print "<h1 align='center'>$msg<br /><br /></h1>";
		}else{
			if($_GET[invid]){
				$qi="select * from invoices where invid='$_GET[invid]'";
				$qi=mysql_query($qi) or die(mysql_error());
				if($inv_row=mysql_fetch_array($qi)){
					$party=substr($party,0,-1);
				}
			}
			?>
			<form action="" method="post" onsubmit="return checkform(this);">
				<table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td align="center" colspan="6">
							<center><h3> Create Product Invoice</h3> </center>
						</td>
					</tr>
					
 					<tr>
						<td colspan="2" align="right"><strong>Party A/C</strong> :</td>
						<td colspan="2">
							<!-- <textarea name="clntid" rows="3" cols="90"><?php echo $party?></textarea> -->
							<?php
							/*$arr=explode(",",$party);
							array_unique($arr);
							$whr="";
							foreach($arr as $k=>$v){
								$whr.=" headid='$v' or ";
							}
							$whr=substr($whr,0,-3);
							$qc="select headid, headname, headaddress from parties where $whr ";
							//echo "$qc <br>";
							$rsp = mysql_query($qc) or die(mysql_error());
							while($rp = mysql_fetch_array($rsp, MYSQL_ASSOC) ){
								echo "<b>$rp[headname]</b> <br />";//<br>$rp[headaddress]
							}*/
							//echo $party;
							?>

							<select style="width:350px;" required name="clntid">
								<option value="">Select</option>
								<?php
								$rs = mysql_query('select headid, headname, headaddress from parties where status="active" && headname like "'. mysql_real_escape_string($_REQUEST['term']) .'%" order by headname ', $dblink);
								$data = array();
								if ( $rs && mysql_num_rows($rs) ){
									while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) ){
										$headid = strip_tags($row['headid']);
										$headname = strip_tags($row['headname']);
										$headaddress = $row['headaddress'];
										if($inv_row['clnid']==$headid){
											$sel="selected";
										}else{
											$sel="";
										}
										?>
										<option <?php echo $sel?> value="<?php echo $headid?>"><?php echo $headname?> <?php echo $headaddress?></option>
										<?php
									}
								}
								?>
							</select>
							<!-- <input type="text" size="110" name="party_name" id="party_name" value="<?php echo $party?>"/> -->
						</td>
					</tr>
				  
					<tr>
						<td colspan="2" align="right"><strong>Date of Issue</strong> :</td>
						<td colspan="2">
							<input type="text" id="issuedate" name="issuedate" class="datepicker" value="<?php echo ($inv_row[dtd]?$inv_row[dtd]:date('Y-m-d')); ?>" />
							<script>
								$(".datepicker").datepicker({
									dateFormat: 'yy-mm-dd'
								});
							</script>
						</td>
					</tr>

					<tr>
						<td colspan="2" align="right">Transportation Mode</td>
						<td colspan="2"><input type="text" name="trans_mode" value="<?php echo $inv_row[supply_place]?>" /></td>
					</tr>
					<tr>
						<td colspan="2" align="right">Vehicle Number</td>
						<td colspan="2"><input type="text" name="vehicle" value="<?php echo $inv_row[vehicle]?>" /></td>
					</tr>
					<tr>
						<td colspan="2" align="right">Date of Supply</td>
						<td colspan="2"><input type="text" class="datepicker" name="supply_dt" value="<?php echo $inv_row[supply_dt]?>" /></td>
					</tr>
					<tr>
						<td colspan="2" align="right">Place of Supply</td>
						<td colspan="2"><input type="text" name="supply_place" value="<?php echo $inv_row[supply_place]?>" /></td>
					</tr>

					<tr>
						<td colspan="4">
							<table width="100%" border="1">
								<tr>
									<th>Sr. No.</th>
									<th>Particulars</th>
									<th>HSN Code</th>
									<th>Quantity</th>
									<th>Rate</th>
								</tr>
								<?php
								$part=explode("~~",$inv_row[particular]);
								$hsncode=explode("~~",$inv_row[hsncode]);
								$qty=explode("~~",$inv_row[qty1]);
								$rate=explode("~~",$inv_row[rate]);
								//print_r($part);
								for($j=1;$j<=3;$j++){
									?>
									<tr>
										<td><?php echo $j?></td>
										<td><textarea name="particular<?php echo $j?>" rows="3" style="width:100%"><?php echo $part[$j-1]?></textarea></td>
										<td><input type="text" name="hsncode<?php echo $j?>" id="hsncode<?php echo $j?>" value="<?php echo $hsncode[$j-1]?>" /></td>
										<td><input type="text" name="qty<?php echo $j?>" id="qty<?php echo $j?>" value="<?php echo $qty[$j-1]?>" ></td>
										<td><input type="text" name="rate<?php echo $j?>" id="rate<?php echo $j?>" value="<?php echo $rate[$j-1]?>" ></td>
									</tr>
									<?php
								}
								?>
							</table>
						</td>
					</tr>
					 
					<!-- <tr>
						<td colspan="2" align="right"><strong>Amount</strong> :</td>
						<td colspan="2">
							<input type="text" size="7" name="amount" value="<?php echo $inv_row[amount]?>" >/- INR</td>
					</tr> -->
					<!-- <tr>
						<td colspan="2" align="right"> Discount:<em>(in %age)</em></td>
						<td colspan="2"><input type="text" name="discount" size="3" value="0" onfocus="this.value=''">%</td>
					</tr> -->
					<tr>
						<td colspan="2" align="right">GST :</td>
						<td colspan="4"><input type="text" name="srtax" value="<?php echo ($inv_row[servicetax]?$inv_row[servicetax]:"18")?>" size="4">%</td>
					</tr>

					<!-- <tr>
						<td colspan="2" align="right">Quantity:</td>
						<td colspan="4"><input type="text" name="qty" size="4" /></td>
					</tr> -->
					<tr>
						<td colspan="2" align="right">Is this IGST? :</td>
						<td colspan="4"><input type="checkbox" name="gst_combine" value="1" /></td>
					</tr>
					<!-- <tr>
						<td colspan="2" align="right">Name of Product/Service:</td>
						<td colspan="4"><input type="text" name="product" size="100"></td>
					</tr> -->
					<!-- <tr>
						<td colspan="2" align="right">Travel Expenses :</td>
						<td colspan="4"><input type="text" name="travel_exp" value="<?php echo $inv_row[travel_exp]?>" size="40"></td>
					</tr>
					<tr>
						<td colspan="2" align="right">Other Expenses :</td>
						<td colspan="4"><input type="text" name="other_exp" value="<?php echo $inv_row[other_exp]?>" size="40"></td>
					</tr> -->
					
					<tr>
						<td colspan="6">
							<center>
								<input type="submit" name="sbmt_btn" value="&raquo; <?php echo($_GET[invid]?"Update":"Create")?> Invoice &raquo;" class="amo-submit">
							</center>
						</td>
					</tr>
				</table>
				
			</form>
			<?php
		}
		?>
	</div>
</div>
<?php
include "templatic/footer.php";
?>


PK 99