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

Hi,

How to create code for auto generate number base on quantity,
For example, I put quantity '999' into form and after I click "submit" system auto generate serial number 1~999 to database table (product_serial_number).

database table : product_serial_number

serial_id | serial_group_id | product_number | serial_number

1 | 55 | 54321 | 1
2 | 55 | 54321 | 2
3 | 55 | 54321 | 3
4 | 55 | 54321 | 4
5 | 55 | 54321 | 5
6 | 55 | 51112 | 1
7 | 55 | 51112 | 2
8 | 55 | 51112 | 3
9 | 55 | 51112 | 4
10 | 55 | 51112 | 5

11 | 55 | 51112 | 6
12 | 55 | 51112 | 7
13 | 55 | 51112 | 8
14 | 55 | 51112 | 9

15 | 55 | 51112 | 10
16 | 55 | 51112 | 11


Form stock_serial_generate.php :
PHP Code:
<?php
        
echo form_open(base_url() . 'index.php/admin/stock/do_generate/', array(
            
'class' => 'form-horizontal',
            
'method' => 'post',
            
'id' => 'generate_serial',
            
'enctype' => 'multipart/form-data'
        
));
    
?>
        <div class="panel-body">

            <input type="hidden" name="product" value="<?php echo $product?>">
            <input type="hidden" name="category" value="<?php echo $this->crud_model->get_type_name_by_id('product',$product,'category'); ?>">
            <input type="hidden" name="sub_category" value="<?php echo $this->crud_model->get_type_name_by_id('product',$product,'sub_category'); ?>">

           
            <div class="form-group">
                <label class="col-sm-4 control-label" for="demo-hor-1"><?php echo translate('current_quantity');?></label>
                <div class="col-sm-6">
                    <input type="number" disabled value="<?php echo $this->crud_model->get_type_name_by_id('product',$product,'current_stock'); ?>" class="form-control totals">
                </div>
            </div>
        </div>
    </form> 


In Controller Admin.php :

PHP Code:
} else if ($para1 == 'do_generate') {
 
           $data['serial_group_id']    = $this->input->post('serial_group_id');
 
           $data['product_number']     = $this->input->post('product_number');
 
           $data['serial_number'     $this->input->post('serial_number');
 
           $this->db->insert('product_serial_number'$data);
 
           recache();
        }

} elseif (
$para1 == 'generate') {

  $this->load->view('back/admin/stock_serial_generate'); 


I'm new with codeigniter, I hope some one can help me.

Attached Files
.php   stock_serial_generate.php (Size: 4 KB / Downloads: 301)
.php   Admin.php (Size: 115.33 KB / Downloads: 231)
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