Image post

 


<div class="container-fluid">
        <div class="row">
            <div class="main-page-container container-fluid">
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                    <?php if(isset($_SESSION['message'])){ ?>
                        <div class="alert alert-success success-msg">
                            <span><?php echo $_SESSION['message'];$_SESSION['message']="";?></span>
                        </div>
                    <?php } ?>
                    <div class="panel panel-default">
                       <div class="panel-heading clearfix">
                          <h2 class="panel-title">Add Service Provider</h2>
                       </div>
                       <form action="<?php echo site_url('admin/serviceprovider'); ?>" method='post' id='myform' enctype="multipart/form-data" class="serviceprovider">
                          <div class="panel-body">
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Name</span>
                                      <input class="form-control" name='name' placeholder="Name" type="text">
                                   </div>
                                </div>
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Mobile No.</span>
                                      <input class="form-control" name='contact' placeholder="Mobile No." type="text">
                                   </div>
                                </div>
                             </div>
                             <div class="row"> &nbsp;</div>
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Email</span>
                                      <input class="form-control" name='email' placeholder="Email" type="text">
                                   </div>
                                </div>
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">
                                        Password
                                      </span>
                                        <input class="form-control" name='password' placeholder="Password" type="password">
                                   </div>
                                </div>
                             </div>
                             <div class="row"> &nbsp;</div>
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group vendorGST">
                                      <span class="input-group-addon">Service Type</span>
                                      <select class="form-control selectpicker" name='service_type[]' multiple>
                                            <?php foreach($servicetype as $servicetype){?>
                                            <option value='<?php echo $servicetype->id;?>'><?php echo $servicetype->category;?></option>
                                            <?php } ?>
                                      </select>
                                   </div>
                                </div>
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">State</span>
                                      <select class="form-control" name="state">
                                         <option value="">Select</option>
                                         <?php foreach($state as $state){?>
                                         <option value="<?php echo $state->state; ?>"><?php echo $state->state; ?></option>
                                         <?php } ?>
                                      </select>
                                   </div>
                                </div>
                            </div>
                             <div class="row"> &nbsp;</div>
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group vendorGST">
                                      <span class="input-group-addon">City</span>
                                      <input class="form-control" name='city' placeholder="City">
                                   </div>
                                </div>
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Address</span>
                                      <input type="text" name='address' placeholder="Address" class='form-control'> 
                                   </div>
                                </div>
                            </div>
                           
                             <div class="row"> &nbsp;</div>
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group vendorGST">
                                      <span class="input-group-addon">Pin</span>
                                      <input class="form-control" name='pin' placeholder="Pin">
                                   </div>
                                </div>
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Adhar No.</span>
                                      <input type="text" name='adharno' placeholder="Adhar No" class='form-control'> 
                                   </div>
                                </div>
                            </div>
                             <div class="row"> &nbsp;</div>
                             <div class="row">
                                <div class="col-lg-6 col-sm-6">
                                   <div class="input-group">
                                      <span class="input-group-addon">Profile Pic</span>
                                      <input type="file" name='profile' class='form-control'></a> 
                                   </div>
                                </div>
                            </div>
                                <div class="row"> &nbsp;</div>
                                <div class="col-lg-6 col-sm-6">
                                   <span>
                                   <input class="btn btn-primary" value="Submit" name='addserviceprovider' type="submit">
                                   </span>
                                   <a href="javascript: window.history.go(-1)" ><input class="btn btn-danger" value="Cancel" type="button"></a>
                                </div>
                             </div>
                       </form>
                       </div>

                       <table id="datatables" class="table table-striped table-bordered custom" width="100%" cellspacing="0">
                        <tfoot class="tfoot classis">
                            <tr>
                                <th>Sno.</th>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Mobile</th>
                                <th>Service Type</th>
                                <th style="display:none">Status</th>
                                <th style="display:none">Action</th>
                            </tr>
                        </tfoot>
                        <thead>
                            <tr>
                                <th>Sno.</th>
                                <th>Name</th>
                                <th>Email</th>
                                <th>Mobile</th>
                                <th>Service Type</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <?php $i=0; foreach($serviceprovider as $serviceprovider){?>
                        <tr>
                            <td><?php  echo $i=$i+1; ?></td>
                            <td><?php  echo $serviceprovider->name; ?></td>
                            <td><?php  echo $serviceprovider->email; ?></td>
                            <td><?php  echo $serviceprovider->contact_no; ?></td>
                            <td><?php  echo $serviceprovider->categoryname; ?></td>
                            <td><?php   if($serviceprovider->status==1){?>
                                        <a href='<?php echo site_url('admin/serviceprovider/'.$serviceprovider->id.'/?status=0'); ?>' title='Active'><i class="fa fa-toggle-on" aria-hidden="true"></i>
                                    <?php } if($serviceprovider->status==0){?>
                                        <a href='<?php echo site_url('admin/serviceprovider/'.$serviceprovider->id.'/?status=1'); ?>' title='Inactive'><i class="fa fa-toggle-off" aria-hidden="true"></i>   
                                    <?php }?></td>
                            <td>
                                <a onclick="return confirm('Are you sure you want to delete?')" href="<?php echo site_url('admin/deleteservicepro/'.$serviceprovider->id); ?>" title='Delete'><i class="fa fa-trash-o" aria-hidden="true"></i></a>
                                <a href="<?php echo site_url('admin/updateservicepro/'.$serviceprovider->id); ?>" title='Details'><i class="fa fa-address-card-o" aria-hidden="true"></i></a>
                            </td>
                        </tr>
                        <?php } ?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

/////////////////////////////////////////////////

  public function serviceprovider()
        {
           
           
            if (isset($_GET['status'])) {
                $urlid  = $this->uri->segment(3);
                $status = (trim($this->input->get('status')));
               
                $updatedata = array(
                    'status' => $status
                );
               
                $whereid   = array(
                    'id' => $urlid
                );
                $is_update = $this->query_model->UPDATEDATA('j1c_services_provider', $whereid, $updatedata);
                if ($is_update) {
                    $this->session->set_flashdata('message', 'Status update successfully.');
                    redirect(site_url('admin/serviceprovider'));
                   
                } else {
                    $this->session->set_flashdata('message', 'Please try again.');
                }
            }
           
            if (isset($_POST['addserviceprovider'])) {
               
                $dir_path = 'assets/images/ServiceProvider';
                if (!is_dir($dir_path)) {
                    mkdir($dir_path, 0777, true);
                }
               
                $config['upload_path']   = $dir_path;
                $config['allowed_types'] = 'gif|jpg|png|jpeg|';
                $this->load->library('upload', $config);
                $this->upload->initialize($config);
               
                if ($this->upload->do_upload('profile')) {
                    $uploadimg   = $this->upload->data();
                    $profile_pic = $uploadimg['file_name'];
                } else {
                    $profile_pic = '';
                }
               
               
                $name        = ucwords(trim($this->input->post('name')));
                $contact     = (trim($this->input->post('contact')));
                $email       = (trim($this->input->post('email')));
                $password    = md5($this->input->post('password'));
                $state       = ucwords(trim($this->input->post('state')));
                $city        = ucwords(trim($this->input->post('city')));
                $address     = ucwords(trim($this->input->post('address')));
                $pin         = trim($this->input->post('pin'));
                $adharno     = ucwords(trim($this->input->post('adharno')));
                $servicetype = ($this->input->post('service_type'));
               
                $insertdata = array(
                    'name' => $name,
                    'contact_no' => $contact,
                    'email' => $email,
                    'password' => $password,
                    'state' => $state,
                    'city' => $city,
                    'address' => $address,
                    'pin' => $pin,
                    'id_proof' => $adharno,
                    'profile_pic' => $profile_pic,
                    'date' => date('Y-m-d h:i:s')
                );
                $is_insert  = $this->query_model->INSERTDATA('j1c_services_provider', $insertdata);
                if ($is_insert) {
                    $where                = array(
                        'email' => $email
                    );
                    $providerid           = ($this->query_model->get_joins('j1c_services_provider', $where));
                    $services_provider_id = $providerid[0]->id;
                   
                   
                   
                    foreach ($servicetype as $service_type) {
                        $insert = array(
                            'services_provider_id ' => $services_provider_id,
                            'service_type_id' => $service_type
                        );
                        $insert = $this->query_model->INSERTDATA('j1c_services_provider_sevicetype', $insert);
                    }
                   
                    $this->session->set_flashdata('message', 'Service provider info submit successfully.');
                } else {
                    $this->session->set_flashdata('message', 'Please try again.');
                }
               
            }
Previous
Next Post »