Welcome Guest, Not a member yet? Register   Sign In
How to generate serial number
#7

(09-05-2016, 08:26 AM)Wouter60 Wrote: Your solution

PHP Code:
$data = array(
'serial_number' =>($i<$count)
); 

won't give the correct result, because ($i < $count) will return the boolean value TRUE, not a number. Replace it with:
PHP Code:
$data = array( 'serial_number' =>$i ); 


Thanks wouter60,

It's work...
* I add code '+ '1'' because system generate serial start from 0 so I put +1 serial start from 1.
PHP Code:
$count $this->input->post('current_stock');
            for(
$i=0$i<$count$i++) {
                
$data = array(
                    
'serial_number' => $i '1',
                    
'product_id' => $id
                
);
                
$this->db->insert('product_serial_number'$data);
            } 

How to set serial number group,
Please correct my code,

PHP Code:
$count $this->input->post('current_stock');
            for(
$i=0$i<$count$i++) {
                
$data = array(
                    
'serial_number' => $i '1',
                    
'product_id' => $id
                
);
                
$this->db->insert('product_serial_number'$data);
            }
            
            
$ser_num_stock $this->db->get_where('product_serial_number', array('serial_number' => ''))->row()->value;
            
$golden = array('1''2''3''4''5''6''7''8''9''11''22''33''44''55''66''77''88''99''111''222''333''444''555''666''777''888''999''1111''2222''3333''4444');
            
$premium = array('10','20','40','50','60','70','80','90','100','101','200','300','303','400','404','500','505','600','606','700','707','800','808','900','909','1000','1001','1010','1100','1122','1133','1144','1155','1166','1177','1188','1199','1212','1221','1313','1331','1414','1441','1515','1551','1616','1661','1717','1771','1818','1881','1919','1991','2000','2002','2020','2112','2121','2200','2211','2233','2244','2255','2266','2277','2288','2299','2323','2332','2424','2442','2525','2552','2626','2662','2727','2772','2828','2882','2929','2992','3000','3003','3030','3113','3131','3232','3344','3355','3366','3377','3388','3399','3434','3443','3535','3553','3636','3663','3737','3773','3838','3883','3939','3993','4000','4004','4040','4114','4141','4224','4242','4334','4343','4400','4411','4242','4433','4455','4466','4477','4488','4499','4545','4554','4646','4664','4747','4774','4848','4884','4949','4994','5000');
            if (
$ser_num_stock == $golden) {
                
$data['serial_group_id']    = '3';
            } elseif (
$ser_num_stock == $premium) {
                
$data['serial_group_id']    = '2';
            } else {
                
$data['serial_group_id']    = '1';
            }
            
$this->db->where('serial_group_id'$data['product_serial_number']);
            
$this->db->update('product_serial_number'$data);
 
           recache(); 

Thanks
Reply


Messages In This Thread
How to generate serial number - by googlemy - 09-02-2016, 12:03 AM
RE: How to generate serial number - by PaulD - 09-02-2016, 04:09 AM
RE: How to generate serial number - by Wouter60 - 09-03-2016, 06:48 AM
RE: How to generate serial number - by googlemy - 09-05-2016, 02:35 AM
RE: How to generate serial number - by Wouter60 - 09-05-2016, 08:26 AM
RE: How to generate serial number - by googlemy - 09-05-2016, 11:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB