Customer Add more address : ps
This commit is contained in:
parent
9129e672b2
commit
afb56f06b0
@ -40,15 +40,17 @@ class Customer extends BaseController
|
||||
if ($id === '0') {
|
||||
$data['page_name'] = 'Add Customer';
|
||||
$data['customer'] = [];
|
||||
$data['customer_billing'] = [];
|
||||
$data['customer_shipping'] = [];
|
||||
} else if ($id !== '0') {
|
||||
$data['page_name'] = 'Edit Customer';
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customers');
|
||||
$edit_user_details = $model->where(['customer_id' => $id])->first();
|
||||
|
||||
$data['customer'] = $edit_user_details;
|
||||
$data['customer_billing'] = $this->get_customer_address($id,1);
|
||||
$data['customer_shipping'] = $this->get_customer_address($id,2);
|
||||
}
|
||||
|
||||
$data['session_bid'] = $session_bid;
|
||||
$this->render_page('customer_form', $data);
|
||||
}
|
||||
@ -59,7 +61,7 @@ class Customer extends BaseController
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new CustomerModel();
|
||||
$model = new CustomerModel();
|
||||
$data = [
|
||||
'first_name' => $this->request->getPost('cfname'),
|
||||
'last_name' => $this->request->getPost('csname'),
|
||||
@ -76,27 +78,88 @@ class Customer extends BaseController
|
||||
'profile_picture' => $this->request->getPost('cfile'),
|
||||
'mode' => $this->request->getPost('cmode'),
|
||||
'business_id' => $this->request->getPost('business_id')
|
||||
|
||||
];
|
||||
|
||||
$customer_id = $this->request->getPost('customer_id'); // Get the business ID for update
|
||||
|
||||
if (empty($customer_id)) {
|
||||
// It's an insert operation
|
||||
$data['isactive'] = 1;
|
||||
$data['created_by'] = $session_uid;
|
||||
//print_r($data);die;
|
||||
$model->insert($data);
|
||||
$FK_CID = $model->insertID(); // for Customer ADDRESS Table
|
||||
} else {
|
||||
// It's an update operation
|
||||
$isactive = $this->request->getPost('isactivce');
|
||||
$isactive = $this->request->getPost('isactive');
|
||||
$data['isactive'] = ($isactive == 'on') ? 1 : 0;
|
||||
$data['updated_by'] = $session_uid;
|
||||
$model->update($customer_id, $data);
|
||||
// $model->update($customer_id, $data);
|
||||
$FK_CID = $customer_id; // for Customer ADDRESS Table
|
||||
}
|
||||
$requestData = $this->request->getPost();
|
||||
$this->save_customer_addresses($FK_CID,$requestData,'b');
|
||||
$this->save_customer_addresses($FK_CID,$requestData,'s');
|
||||
return redirect()->route('customer_list');
|
||||
}
|
||||
|
||||
public function save_customer_addresses($id,$requestData,$letteringflag){
|
||||
|
||||
$addressType = ($letteringflag == 'b') ? 1 : 2;
|
||||
$getAddressdetails = $this->get_customer_address($id,$addressType);
|
||||
$CAid = $requestData[$letteringflag.'customer_address_id']; // Available Address IDS in Form Fields.
|
||||
$model = new CustomerModel();
|
||||
|
||||
// Compare Address Input Field PKIDS With Existing PKIDS
|
||||
// IF Any Missing value Means that values are Inactive here....
|
||||
if(!empty($CAid)){
|
||||
$filteringAddressIds = [];
|
||||
for ($y = 0; $y < count($getAddressdetails); $y++) {
|
||||
$filteringAddressIds[$y] = $getAddressdetails[$y]['customer_address_id'];
|
||||
}
|
||||
if(!empty($filteringAddressIds)){
|
||||
$A = $filteringAddressIds;
|
||||
$B = $CAid;
|
||||
$missingValues = array_diff($A,$B);
|
||||
if(!empty($missingValues)){
|
||||
$where = ['isactive'=>1,'customer_id'=>(int)$id,'address_type'=>$addressType];
|
||||
$model->inactiveMissingAddressDetails($where,$missingValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
$session_uid = get_logged_user_id();
|
||||
|
||||
$baddress1 = $requestData[$letteringflag.'address1'];
|
||||
$baddress2 = $requestData[$letteringflag.'address2'];
|
||||
$bcountry = $requestData[$letteringflag.'country'];
|
||||
$bcity = $requestData[$letteringflag.'city'];
|
||||
$bstate = $requestData[$letteringflag.'state'];
|
||||
$bzip = $requestData[$letteringflag.'zip'];
|
||||
$count = count($CAid);
|
||||
$address_array = [];
|
||||
if($count > 0){
|
||||
for ($x = 0; $x < $count; $x++) {
|
||||
$address_array[$x]['first_name'] = $requestData['cfname'];
|
||||
$address_array[$x]['last_name'] = $requestData['csname'];
|
||||
// $address_array[$x]['company'] = "";
|
||||
$address_array[$x]['email'] = $requestData['cmail'];
|
||||
$address_array[$x]['mobile_no'] = $requestData['cmobile'];
|
||||
$address_array[$x]['address_1'] = $baddress1[$x];
|
||||
$address_array[$x]['address_2'] = $baddress2[$x];
|
||||
$address_array[$x]['city'] = $bcity[$x];
|
||||
$address_array[$x]['state'] = $bstate[$x];
|
||||
$address_array[$x]['country'] = $bcountry[$x];
|
||||
$address_array[$x]['postal_code'] = $bzip[$x];
|
||||
$address_array[$x]['customer_id'] = $id;
|
||||
$address_array[$x]['address_type'] = $addressType;
|
||||
$address_array[$x]['created_by'] = $session_uid;
|
||||
$address_array[$x]['updated_by'] = $CAid[$x] ? $session_uid : null;
|
||||
$address_array[$x]['customer_address_id'] = $CAid[$x];
|
||||
}
|
||||
$statement = $model->saveAddressDetails($address_array);
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
|
||||
## For delete the customer details (Which means inactive the details)
|
||||
public function delete_customer($id)
|
||||
{
|
||||
@ -121,6 +184,13 @@ class Customer extends BaseController
|
||||
return redirect()->route('customer_list');
|
||||
}
|
||||
|
||||
public function get_customer_address($id,$type){
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_addresses');
|
||||
$where = ['isactive' => 1, 'customer_id' => (int)$id,'address_type'=>(int)$type];
|
||||
$address_details = $model->where($where)->findAll();
|
||||
return $address_details;
|
||||
}
|
||||
## ApiIntegration For Customer.
|
||||
public function apiintegration()
|
||||
{
|
||||
|
||||
@ -1,17 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Models\BooksModel;
|
||||
use App\Models\HomeModel;
|
||||
|
||||
## Home Controllers only for Dashboards,Report Modules
|
||||
class Home extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data['page_name'] = 'Dashboard';
|
||||
helper('session');
|
||||
$session_role = get_user_role();
|
||||
$session_bid = get_business_id();
|
||||
$data['page_name'] = 'Dashboard';
|
||||
if (!empty($session_role) && $session_role !== "sadmin") {
|
||||
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
|
||||
} else if (!empty($session_role) && $session_role !== "admin") {
|
||||
$where = ['isactive != ' => NULL];
|
||||
} else {
|
||||
$where = [];
|
||||
}
|
||||
$model = new HomeModel();
|
||||
$data['customer'] = $model->customers($where);
|
||||
$data['customer']['label'] = "Customer";
|
||||
$this->render_page('dashboard', $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ class CustomerModel extends Model
|
||||
{
|
||||
protected $table = 'customers';
|
||||
protected $primaryKey = 'customer_id ';
|
||||
protected $allowedFields = ['customer_id ','first_name','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','type','isactive','business_id'];
|
||||
protected $allowedFields = ['customer_id ','first_name','city','last_name','email','mobile_no','country','state','postal_code' ,'address','profile_picture','date_of_birth','gender','mode','type','isactive','business_id'];
|
||||
|
||||
public function insertCustomer($data)
|
||||
{
|
||||
@ -25,5 +25,30 @@ class CustomerModel extends Model
|
||||
$this->db->table('customer_addresses')->insertBatch($addressesDataArray);
|
||||
return $this->db->insertID(); // Note: insertID() might not be applicable for batch inserts
|
||||
}
|
||||
|
||||
public function saveAddressDetails($data){
|
||||
$i = 0;
|
||||
$statement = [];
|
||||
foreach ($data as $row) {
|
||||
$id = $row['customer_address_id'];
|
||||
if($id != ''){
|
||||
unset($row['customer_address_id']); // Remove the id from the data to avoid updating it
|
||||
unset($row['created_by']); // bcoz here data Updating here.
|
||||
$this->db->table('customer_addresses')->where('customer_address_id', $id)->update($row);// Update the row with the specified id
|
||||
$affectedRows = $this->db->affectedRows();
|
||||
$statement[$i] = "address - ".$id." ".$affectedRows ? " Updated":" Not Updated";
|
||||
}else{
|
||||
|
||||
$this->db->table('customer_addresses')->insert($row);
|
||||
$insertID = $this->db->insertID();
|
||||
$statement[$i] = "address - ".$insertID." Inserted";
|
||||
}
|
||||
}
|
||||
return $statement;
|
||||
}
|
||||
public function inactiveMissingAddressDetails($where,$missingValues){
|
||||
$dataToUpdate = ['isactive' => 0];
|
||||
$this->db->table('customer_addresses')->where($where)->whereIn('customer_address_id',$missingValues)->update($dataToUpdate);
|
||||
}
|
||||
}
|
||||
?>
|
||||
27
app/Models/HomeModel.php
Normal file
27
app/Models/HomeModel.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class HomeModel extends Model
|
||||
{
|
||||
|
||||
public function customers($where) {
|
||||
$query = $this->db->table('customers');
|
||||
|
||||
$totalCustomers = $query->where($where)->countAll();
|
||||
$activeCustomers = $query->where($where)->countAllResults();
|
||||
|
||||
$where['DATE(created_on)'] = date('Y-m-d');
|
||||
$todayCustomers = $query->where($where)->countAllResults();
|
||||
|
||||
if ($totalCustomers > 0) {
|
||||
$customer['percentage'] = ($activeCustomers / $totalCustomers) * 100;
|
||||
} else {
|
||||
$customer['percentage'] = 0;
|
||||
}
|
||||
|
||||
$customer['total'] = $totalCustomers;
|
||||
$customer['active'] = $activeCustomers;
|
||||
$customer['today'] = $todayCustomers;
|
||||
return $customer;
|
||||
}
|
||||
}
|
||||
@ -7,85 +7,74 @@
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?php echo base_url(); ?>insert_customer">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cfname" class="col-form-label">First Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="cfname" name="cfname" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="csname" class="col-form-label">Last Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="csname" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cmail" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="cmail" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cmobile" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cmobile" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<div class="input-group mb-2">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text">+91</div>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required pattern="\d*" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="dob" class="col-form-label">Date Of Birth<span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" name="dob" value="<?= isset($customer['date_of_birth']) ? $customer['date_of_birth'] : '' ?>" placeholder="Date Of Birth" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gen" class="col-form-label">Gender<span class="text-danger">*</span></label>
|
||||
<input type="rad" class="form-control" name="gen" value="<?= isset($customer['gender']) ? $customer['gender'] : '' ?>" placeholder="Gender" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="caddress" class="col-form-label">Address<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="address" value="<?= isset($customer['address']) ? $customer['address'] : '' ?>" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="ccountry" class="col-form-label">Country<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="ccountry" value="<?= isset($customer['country']) ? $customer['country'] : '' ?>" placeholder="Country" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="ccity" class="col-form-label">City<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="ccity" value="<?= isset($customer['city']) ? $customer['city'] : '' ?>" placeholder="City" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cstate" class="col-form-label">State<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="cstate" value="<?= isset($customer['state']) ? $customer['state'] : '' ?>" placeholder="State" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="czip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="czip" value="<?= isset($customer['postal_code']) ? $customer['postal_code'] : '' ?>" placeholder="Postal Code (PIN)" required />
|
||||
<input type="text" class="form-control" name="czip" value="<?= isset($customer['postal_code']) ? $customer['postal_code'] : '' ?>" placeholder="Postal Code (PIN)" required pattern="\d*" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="ctype" class="col-form-label">Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="ctype" value="<?= isset($customer['type']) ? $customer['type'] : '' ?>" placeholder="Customer/Subscriebr" required />
|
||||
@ -97,8 +86,141 @@
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="customer_id" name="customer_id" placeholder="hidden for book id" value="<?= isset($customer['customer_id']) ? $customer['customer_id'] : '' ?>" />
|
||||
<input type="hidden" id="customer_id" name="customer_id" placeholder="hidden for customer id" value="<?= isset($customer['customer_id']) ? $customer['customer_id'] : '' ?>" />
|
||||
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= $session_bid ?>" />
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<br />
|
||||
<h5> Billing Address </h5>
|
||||
<div class="after-add-more">
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<!-- <div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="bfname" class="col-form-label">First Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bfname" name="bfname[]" value="<?= isset($customer['first_name']) ? $customer['first_name'] : '' ?>" placeholder="First Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="blname" class="col-form-label">Last Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="blname" name="blname[]" value="<?= isset($customer['last_name']) ? $customer['last_name'] : '' ?>" placeholder="Last Name" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bcname" class="col-form-label">Company<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bcname" name="bcname[]" value="<?= isset($customer['Company']) ? $customer['Company'] : '' ?>" placeholder="Company" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bemail" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bemail" name="bemail[]" value="<?= isset($customer['email']) ? $customer['email'] : '' ?>" placeholder="Email" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="bmobile" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="bmobile" name="bmobile[]" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="baddress1" class="col-form-label">Address 1<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="baddress1" name="baddress1[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="baddress2" class="col-form-label">Address 2<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="baddress2" name="baddress2[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bcountry" class="col-form-label">Country<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bcountry" name="bcountry[]" placeholder="Country" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bcity" class="col-form-label">City<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bcity" name="bcity[]" placeholder="City" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cstate" class="col-form-label">State<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bstate" name="bstate[]" placeholder="State" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="bzip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="bzip" name="bzip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<input type="hidden" id="bcustomer_address_id" name="bcustomer_address_id[]" placeholder="hidden for billing customer address id" />
|
||||
</div>
|
||||
<div class="form-group col-md-9 change text-right m-b-0"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<a class="btn btn-success add-more">+ Add More Billing Address </a>
|
||||
</div>
|
||||
<br />
|
||||
<h5> Shipping Address </h5>
|
||||
<div class="after-add-smore">
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="saddress1" class="col-form-label">Address 1<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="saddress1" name="saddress1[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="saddress2" class="col-form-label">Address 2<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="saddress2" name="saddress2[]" placeholder="Address (eg : 1234 Main St)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="scountry" class="col-form-label">Country<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="scountry" name="scountry[]" placeholder="Country" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="scity" class="col-form-label">City<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="scity" name="scity[]" placeholder="City" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="sstate" class="col-form-label">State<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="sstate" name="sstate[]" placeholder="State" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="szip" class="col-form-label">Postal Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="szip" name="szip[]" placeholder="Postal Code" required pattern="\d*" maxlength="10" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<input type="hidden" id="scustomer_address_id" name="scustomer_address_id[]" placeholder="hidden for shipping customer address id" />
|
||||
</div>
|
||||
<div class="form-group col-md-9 schange text-right m-b-0"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<a class="btn btn-success add-smore">+ Add More Shipping Address </a>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($customer)) { ?>
|
||||
<div class="form-group text-right m-b-0 checkbox checkbox-purple">
|
||||
<input type="checkbox" id="isactive" name="isactive" class="form-control" <?= isset($customer) && $customer['isactive'] == 1 ? 'checked' : '' ?>>
|
||||
@ -115,9 +237,80 @@
|
||||
</button>
|
||||
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- end card-body-->
|
||||
</div> <!-- end card-->
|
||||
</div> <!-- end col-->
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var barray = <?php echo json_encode($customer_billing); ?>;
|
||||
if (barray.length > 0) {
|
||||
for (var i = 0; i < barray.length; i++) {
|
||||
if (i == 0) {
|
||||
var html = $(".after-add-more").first();
|
||||
} else {
|
||||
var html = $(".after-add-more").first().clone();
|
||||
}
|
||||
html.find('input#bcustomer_address_id').val(barray[i]['customer_address_id']);
|
||||
html.find('input#baddress1').val(barray[i]['address_1']);
|
||||
html.find('input#baddress2').val(barray[i]['address_2']);
|
||||
html.find('input#bcity').val(barray[i]['city']);
|
||||
html.find('input#bstate').val(barray[i]['state']);
|
||||
html.find('input#bcountry').val(barray[i]['country']);
|
||||
html.find('input#bzip').val(barray[i]['postal_code']);
|
||||
if (i !== 0) {
|
||||
html.find(".change").html("<label for=''> </label><br/><a class='btn btn-danger remove'>- Remove</a>");
|
||||
html.insertAfter(".after-add-more:last");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("body").on("click", ".add-more", function() {
|
||||
var html = $(".after-add-more").first().clone();
|
||||
html.find('input').val(''); // Clear input values in the cloned element
|
||||
html.find(".change").html("<label for=''> </label><br/><a class='btn btn-danger remove'>- Remove</a>");
|
||||
html.insertAfter(".after-add-more:last");
|
||||
});
|
||||
|
||||
$("body").on("click", ".remove", function() {
|
||||
$(this).parents(".after-add-more").remove();
|
||||
});
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
var sarray = <?php echo json_encode($customer_shipping); ?>;
|
||||
if (sarray.length > 0) {
|
||||
for (var i = 0; i < sarray.length; i++) {
|
||||
if (i == 0) {
|
||||
var html = $(".after-add-smore").first();
|
||||
} else {
|
||||
var html = $(".after-add-smore").first().clone();
|
||||
}
|
||||
html.find('input#scustomer_address_id').val(sarray[i]['customer_address_id']);
|
||||
html.find('input#saddress1').val(sarray[i]['address_1']);
|
||||
html.find('input#saddress2').val(sarray[i]['address_2']);
|
||||
html.find('input#scity').val(sarray[i]['city']);
|
||||
html.find('input#sstate').val(sarray[i]['state']);
|
||||
html.find('input#scountry').val(sarray[i]['country']);
|
||||
html.find('input#szip').val(sarray[i]['postal_code']);
|
||||
if (i !== 0) {
|
||||
html.find(".schange").html("<label for=''> </label><br/><a class='btn btn-danger sremove'>- Remove</a>");
|
||||
html.insertAfter(".after-add-smore:last");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$("body").on("click", ".add-smore", function() {
|
||||
var html = $(".after-add-smore").first().clone();
|
||||
html.find('input').val(''); // Clear input values in the cloned element
|
||||
html.find(".schange").html("<label for=''> </label><br/><a class='btn btn-danger sremove'>- Remove</a>");
|
||||
html.insertAfter(".after-add-smore:last");
|
||||
});
|
||||
|
||||
$("body").on("click", ".sremove", function() {
|
||||
$(this).parents(".after-add-smore").remove();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@ -5,13 +5,25 @@
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="knob-chart" dir="ltr">
|
||||
<input data-plugin="knob" data-width="70" data-height="70" data-fgColor="#1abc9c"
|
||||
data-bgColor="#d1f2eb" value="58"
|
||||
data-bgColor="#d1f2eb" value="<?= $customer['percentage']; ?>"
|
||||
data-skin="tron" data-angleOffset="0" data-readOnly=true
|
||||
data-thickness=".15"/>
|
||||
</div>
|
||||
<!-- <div class="text-right">
|
||||
<h3 class="mb-1 mt-0"> <span data-plugin="counterup"><?= $customer['active']; ?></span> </h3>
|
||||
<p class="text-muted mb-0"><?= 'Available '.$customer['label']; ?></p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<h3 class="mb-1 mt-0"> <span data-plugin="counterup"><?= $customer['total']; ?></span> </h3>
|
||||
<p class="text-muted mb-0"><?= 'Total '.$customer['label']; ?></p>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<h3 class="mb-1 mt-0"> <span data-plugin="counterup">268</span> </h3>
|
||||
<p class="text-muted mb-0">New Customers</p>
|
||||
</div> -->
|
||||
<div class="text-right">
|
||||
<h3 class="mb-1 mt-0"> <span data-plugin="counterup"><?= $customer['today']; ?></span> </h3>
|
||||
<p class="text-muted mb-0"><?= 'New '.$customer['label']; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
|
||||
<ul id="side-menu">
|
||||
<li>
|
||||
<a href="dashboard">
|
||||
<a href="<?= base_url()."dashboard"; ?>">
|
||||
<i class="ri-dashboard-line"></i>
|
||||
<!-- <span class="badge badge-success badge-pill float-right">3</span> -->
|
||||
<span> Dashboard </span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user