Пример #1
0
 public function test()
 {
     $arr = array(array('m', 'au', 100000000000, 0.6684587122268445), array('au', 'm', 2, 299195741400), array('m', 'ft', 100, 328.083332904091), array('ft', 'm', 100, 30.480061), array('m', 'in', 100, 3937.0078740157483), array('in', 'm', 100, 2.54), array('m', 'yd', 1000, 1093.6132983377079), array('yd', 'm', 1000, 914.4), array('usmile', 'm', 1.5, 2414.016), array('m', 'usmile', 1000, 0.6213711922373339), array('ukmile', 'm', 1.5, 2778), array('m', 'ukmile', 300, 0.16198704103671707), array('mm', 'yd', 500, 0.5468066491688539), array('yd', 'mm', 0.25, 228.6), array('mm', 'nm', 10, 10000000), array('nm', 'mm', 500000, 0.5), array('pm', 'nm', 500000, 500), array('nm', 'pm', 0.04, 40), array('fm', 'pm', 50000000, 50000), array('am', 'fm', 50000000, 50000), array('zm', 'am', 50000000, 50000), array('ym', 'zm', 50000000, 50000), array('km', 'ld', 500000, 1.3007284079084287), array('meter', 'cm', 1, 100), array('mil', 'kilometer', 10, 100), array('micrometer', 'nanometer', 1, 1000));
     foreach ($arr as $test) {
         $res = ConvertLength::convert($test[0], $test[1], $test[2]);
         $this->assertEquals($res, $test[3]);
     }
 }
Пример #2
0
	function insertIntoGroup($module='',$module_id='',$inventory_id='',$inventory_name='',$last_assign_id='',$rework_id='',$order_id='',$measured_in=''){
		ob_start();
			
		  if( $module == 'work order' ){
				$sql_sub = "select gp_id,product_id from ".erp_PRODUCT_ORDER." where workorder_id = '$module_id'";
				//echo $sql_sub;
				$result_sub = $this->db->query($sql_sub,__FILE__,__LINE__);
				$row_sub = $this->db->fetch_array($result_sub);
				
				if( $row_sub[gp_id] == 0 )
				{ $product = $module_id; }
				else
				{ $product = $gp_id; }
		  
		  
			 $sql_inch = "SELECT size,quantity FROM ".erp_SIZE." WHERE product_id = '$product' and order_id = '$order_id'";
			 //$sql_inch = "SELECT size,quantity FROM erp_size WHERE product_id = '28' and order_id = '7'";
			 //echo $sql_inch;
			 $result_inch = $this->db->query($sql_inch,__FILE__,__LINE__);					 
			 while( $row_inch = $this->db->fetch_array($result_inch) ){
					$inch_array = explode("_",$row_inch[size]);
					$field_name = strtolower($inch_array[1]).'_inventory_usage';
					
					$sql_consumable = "Select $field_name from ".erp_ASSIGN_INVENTORY." where product_id = '$row_sub[product_id]' and group_inventory_id='0' and inventory_id = '$inventory_id'";
					//echo $sql_consumable.'<br>';
					$result_consumable = $this->db->query($sql_consumable,__FILE__,__LINE__);
					$row_consumable = $this->db->fetch_array($result_consumable);
					$inch += ($row_consumable[$field_name] * $row_inch[quantity]);
					
					//echo $inch.'aaaaaaa<br>';
			 }
		 } else {
			 $sql_re = "SELECT distinct rework_id, fabric_scrap FROM ".erp_REWORK." WHERE product_id = '$module_id' and order_id = '$order_id'";
			 //echo $sql_re;
			 $result_re = $this->db->query($sql_re,__FILE__,__LINE__);
			 $row_re = $this->db->fetch_array($result_re);
			 $inch = $row_re[fabric_scrap];
			 $rework_id = $row_re[rework_id];
			 
		   }
			
			$obj = new ConvertLength();
			
			
			$sql_gd_id="SELECT * FROM " . erp_GROUP . " where order_id='$order_id' and workorder_id='$module_id' ORDER BY g_id DESC";
			$result_id =$this->db->query($sql_gd_id);
			$row_gd_id=$this->db->fetch_array($result_id);
			$gd_id=$row_gd_id[group_id];
			
			if($gd_id==0)
			   $gd_id=1;
			else
			   $gd_id +=1;
			
			//echo $inch.'aaaaaaaaaa';
			$individual_inch = round($obj->convert($measured_in,"Inches",$inch),2);
			$total_inch = $individual_inch + $row_gd_id['total_inch'];
			
			if($row_gd_id[group_id]){
				$insert_sql_array[group_id] = $row_gd_id[group_id];
				$insert_sql_array[assign_fct_id] = $last_assign_id;
				$insert_sql_array[type] = $module;
				$insert_sql_array[rework_id] = $rework_id;
				$insert_sql_array[fabric_id] = $inventory_id;
				$insert_sql_array[inches] = $individual_inch;
				$insert_sql_array[created] = date("y-m-d");
				$insert_sql_array[inventory_name] = $inventory_name;
				$insert_sql_array[workorder_id] = $module_id;
				$insert_sql_array[order_id] = $order_id;
				$insert_sql_array[total_inch] = $total_inch;
				//print_r($insert_sql_array);
				
				$this->db->insert(erp_GROUP,$insert_sql_array);
			}
			
			$sql_q= $this->db->query("UPDATE erp_create_group SET total_inch = '" . $total_inch . "' WHERE group_id = '". $row_gd_id[group_id] ."' ");
		$html=ob_get_contents();
		ob_end_clean();
		return $html;
	}