ADD_NEW_NONE_IGR_EXPENSE

This commit is contained in:
aadhavan valli 2024-08-27 11:31:42 +05:30
parent eeabe9da98
commit 96ff383906
3456 changed files with 4757 additions and 528539 deletions

9
.gitignore vendored
View File

@ -1,3 +1,8 @@
# Ignore Composer files
vendor
composer.lock
# Ignore PHPStorm files
/.idea/*
*.sublime-*
@ -111,9 +116,7 @@ php_errors.log
/app/Views/*.tmp
# Ignore Composer files
vendor
composer.lock
# Ignore environment-specific settings
.env

View File

@ -31,6 +31,7 @@ $routes->get('reports', 'Report::index');
// User Routes
$routes->get('addNew', 'User::addNew');
$routes->post('fetchEmployeeDetails', 'User::fetchEmployeeDetails');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'addNewUser', 'User::addNewUser');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'userListing', 'User::userListing');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'userListing/(:num)', 'User::userListing/$1');
@ -72,6 +73,8 @@ $routes->get('exportcost', 'CostCenter::exportcost');
// Asset Detail Routes
$routes->get('assetListing', 'Assetdetails::assetListing');
$routes->get('addasset', 'Assetdetails::addasset');
$routes->get('assetdetails/editOldasset', 'Assetdetails::editOldasset');
// $routes->post('addNewasset', 'Assetdetails::addNewasset');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editOldasset', 'Assetdetails::editasset');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editOldasset/(:num)', 'Assetdetails::editasset/$1');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editasset', 'Assetdetails::editasset');
@ -259,6 +262,13 @@ $routes->get('download-files/(:segment)', 'Inwardgateregister::downloadFilesAsZi
$routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituploadfile');
// Non IGR / Expense
$routes->get('ListIGR', 'Expense::index');
$routes->post('addExpense', 'Expense::addExpense');
$routes->get('getExpenseDetails', 'Expense::getExpenseDetails');
// Application OGR Page
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'AddOgr', 'Inwardgateregister::addoutwardgateregister');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'ViewOgr', 'Inwardgateregister::ViewOgr');

View File

@ -66,7 +66,7 @@ class Assetdetails extends BaseController
$data['AssetStatus'] = $this->assetdetails_model->getConfigValue('C015');
$data['po'] = $this->assetdetails_model->getPO();
//print_r($data);die();
// print_r($data);die();
$this->global['pageTitle'] = 'Add Asset';
$this->loadViews("addasset", $this->global, $data, NULL);
@ -186,47 +186,48 @@ class Assetdetails extends BaseController
function addNewasset()
{
$this->validator->setRules([
'AssetName' => 'trim|required',
'Department' => 'trim|callback_Department_validate',
'Location' => 'trim|required',
'User' => 'trim|required',
'SupplierName' => 'trim|callback_Supplier_validate',
'DateOfCommission' => 'trim|required',
'Assetvalue' => 'trim|required',
'AssetStatus' => 'trim|callback_Asset_validate'
]);
// $this->validator->setRules([
// 'AssetName' => 'trim|required',
// 'Department' => 'trim|callback_Department_validate',
// 'Location' => 'trim|required',
// 'User' => 'trim|required',
// 'SupplierName' => 'trim|callback_Supplier_validate',
// 'DateOfCommission' => 'trim|required',
// 'Assetvalue' => 'trim|required',
// 'AssetStatus' => 'trim|callback_Asset_validate'
// ]);
$this->validator->setMessage([
'AssetName' => [
'required' => 'Please enter Asset Name.'
],
'Department' => [
'Department_validate' => 'Please select a valid Department.'
],
'Location' => [
'required' => 'Please enter Location.'
],
'User' => [
'required' => 'Please enter User.'
],
'SupplierName' => [
'Supplier_validate' => 'Please select a valid Supplier.'
],
'DateOfCommission' => [
'required' => 'Please enter Date of Commission.'
],
'Assetvalue' => [
'required' => 'Please enter Asset Value.'
],
'AssetStatus' => [
'Asset_validate' => 'Please select a valid Asset Status.'
]
]);
// $this->validator->setMessage([
// 'AssetName' => [
// 'required' => 'Please enter Asset Name.'
// ],
// 'Department' => [
// 'Department_validate' => 'Please select a valid Department.'
// ],
// 'Location' => [
// 'required' => 'Please enter Location.'
// ],
// 'User' => [
// 'required' => 'Please enter User.'
// ],
// 'SupplierName' => [
// 'Supplier_validate' => 'Please select a valid Supplier.'
// ],
// 'DateOfCommission' => [
// 'required' => 'Please enter Date of Commission.'
// ],
// 'Assetvalue' => [
// 'required' => 'Please enter Asset Value.'
// ],
// 'AssetStatus' => [
// 'Asset_validate' => 'Please select a valid Asset Status.'
// ]
// ]);
if (!$this->validator->run()) {
$this->addasset();
// if (!$this->validator->run()) {
if (false) {
// $this->addasset();
} else {
$assetName = $this->request->getPost('AssetName');
$AssetName = (!empty($assetName)) ? strtoupper((string)$assetName) : "";
@ -273,11 +274,11 @@ class Assetdetails extends BaseController
if ($result > 0) {
// $this->session->set_flashdata('success', 'New Asset created successfully');
echo "<script>alert('Asset Created successfully!');</script>";
redirect('assetListing', 'refresh');
} else {
// $this->session->set_flashdata('failed', 'Asset Created Failed!');
echo "<script>alert('Asset Not Created!');</script>";
redirect('assetListing', 'refresh');
}
return redirect()->route('assetListing');
}
}
/**
@ -325,49 +326,50 @@ class Assetdetails extends BaseController
$Asset_Code = $this->request->getPost('AssetCode');
$this->validator->setRules([
'AssetName' => 'trim|required',
'Description' => 'trim|required',
'Department' => 'trim|callback_Department_validate',
'Location' => 'trim|required',
'User' => 'trim|required',
'SupplierName' => 'trim|callback_Supplier_validate',
'DateOfCommission' => 'trim|required',
'Assetvalue' => 'trim|required',
'AssetStatus' => 'trim|callback_Asset_validate'
]);
// $this->validator->setRules([
// 'AssetName' => 'trim|required',
// 'Description' => 'trim|required',
// 'Department' => 'trim|callback_Department_validate',
// 'Location' => 'trim|required',
// 'User' => 'trim|required',
// 'SupplierName' => 'trim|callback_Supplier_validate',
// 'DateOfCommission' => 'trim|required',
// 'Assetvalue' => 'trim|required',
// 'AssetStatus' => 'trim|callback_Asset_validate'
// ]);
$this->validator->setMessage([
'AssetName' => [
'required' => 'Please enter Asset Name.'
],
'Description' => [
'required' => 'Please enter Description.'
],
'Department' => [
'Department_validate' => 'Please select a valid Department.'
],
'Location' => [
'required' => 'Please enter Location.'
],
'User' => [
'required' => 'Please enter User.'
],
'SupplierName' => [
'Supplier_validate' => 'Please select a valid Supplier.'
],
'DateOfCommission' => [
'required' => 'Please enter Date of Commission.'
],
'Assetvalue' => [
'required' => 'Please enter Asset Value.'
],
'AssetStatus' => [
'Asset_validate' => 'Please select a valid Asset Status.'
]
]);
// $this->validator->setMessage([
// 'AssetName' => [
// 'required' => 'Please enter Asset Name.'
// ],
// 'Description' => [
// 'required' => 'Please enter Description.'
// ],
// 'Department' => [
// 'Department_validate' => 'Please select a valid Department.'
// ],
// 'Location' => [
// 'required' => 'Please enter Location.'
// ],
// 'User' => [
// 'required' => 'Please enter User.'
// ],
// 'SupplierName' => [
// 'Supplier_validate' => 'Please select a valid Supplier.'
// ],
// 'DateOfCommission' => [
// 'required' => 'Please enter Date of Commission.'
// ],
// 'Assetvalue' => [
// 'required' => 'Please enter Asset Value.'
// ],
// 'AssetStatus' => [
// 'Asset_validate' => 'Please select a valid Asset Status.'
// ]
// ]);
if ($this->validator->run() == FALSE) {
// if ($this->validator->run() == FALSE) {
if (FALSE) {
$this->editOldasset($Asset_Code);
} else {
@ -419,11 +421,10 @@ class Assetdetails extends BaseController
if ($result == true) {
echo "<script>alert('Asset updated successfully!');</script>";
redirect('assetListing', 'refresh');
} else {
echo "<script>alert('Asset Not updated !');</script>";
redirect('assetListing', 'refresh');
}
return redirect()->route('assetListing');
}
}

105
app/Controllers/Expense.php Normal file
View File

@ -0,0 +1,105 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\Expense_model;
use App\Models\Supplier_model;
class Expense extends BaseController
{
protected $expense_model;
protected $supplier_model;
protected $session;
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->expense_model = new Expense_model();
$this->supplier_model = new Supplier_model();
$this->session = session();
helper('form'); //$this->load->library('form_validation');
$this->isLoggedIn();
}
public function index()
{
$data['expense_list'] = $this->expense_model->getAllExpense();
$data['supplier_list'] = json_encode($this->supplier_model->supplierlisting());
$this->global['pageTitle'] = 'Non IGR / Expense List';
// echo "<pre>";
// print_r($data);die;
$this->loadViews("expense_list", $this->global, $data, NULL);
}
function addExpense()
{
$data = array(
'transporter_file' => $this->request->getPost('transporterfile'),
'supplier_id' => $this->request->getPost('supplierid'),
'remarks' => $this->request->getPost('remarks'),
'cost' => $this->request->getPost('cost'),
'gst' => $this->request->getPost('gst'),
'total' => $this->request->getPost('total'),
'status' => $this->request->getPost('status'),
'payment_method' => $this->request->getPost('payment_method')
);
$insert_id = $this->expense_model->insertExpense($data);
if ($insert_id) {
// Return success response or redirect
// $this->session->set_flashdata('success', 'Expense added successfully.');
// redirect('your_controller/your_method'); // Replace with your redirect path
return json_encode('true');
} else {
// Return error response
// $this->session->set_flashdata('error', 'Failed to add expense.');
// redirect('your_controller/your_method'); // Replace with your redirect path
return json_encode('false');
}
}
public function getExpenseDetails() {
$id = $this->request->getPost('id');
if ($id) {
$expense = $this->expense_model->getExpenseById($id);
echo json_encode($expense);
} else {
echo json_encode(['error' => 'Invalid ID']);
}
}
public function updateExpense() {
// $id = $this->input->post('id');
// $data = [
// 'transporterfile' => $this->input->post('transporterfile'),
// 'supplierid' => $this->input->post('supplierid'),
// 'remarks' => $this->input->post('remarks'),
// 'cost' => $this->input->post('cost'),
// 'gst' => $this->input->post('gst'),
// 'total' => $this->input->post('total'),
// 'status' => $this->input->post('status'),
// 'payment_method' => $this->input->post('payment_method')
// ];
// if ($id) {
// $result = $this->Expense_model->updateExpense($id, $data);
// if ($result) {
// echo json_encode(['success' => 'Expense updated successfully']);
// } else {
// echo json_encode(['error' => 'Failed to update expense']);
// }
// } else {
// echo json_encode(['error' => 'Invalid ID']);
// }
}
}

View File

@ -917,14 +917,10 @@ class User extends BaseController
// else
// {
$data['EmpList'] = $this->user_model->getAllEmployees();
$data['roles'] = $this->user_model->getUserRoles();
// $data['Department'] = $this->costcenter_model->getDepartment();
$this->global['pageTitle'] = 'Add New User';
$this->loadViews("addUser", $this->global, $data, NULL);
// }
}
@ -1637,4 +1633,19 @@ class User extends BaseController
}
// END zoho API
}
function fetchEmployeeDetails() {
$EmpID = $this->request->getPost('EmpID');
if (!$EmpID) {
return $this->response->setJSON(['success' => false, 'message' => 'Employee ID not provided']);
}
$userInfo = $this->user_model->findEmp($EmpID);
if ($userInfo) {
return $this->response->setJSON(['success' => true, 'userInfo' => $userInfo]);
} else {
return $this->response->setJSON(['success' => false, 'message' => 'Employee not found']);
}
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class Expense_model extends Model
{
protected $table = 't_expense'; // Table name
protected $primaryKey = 'id'; // Primary key
protected $allowedFields = [
'transporterfile', 'supplier_id', 'remarks', 'cost', 'gst', 'total', 'status', 'payment_method'
];
// Retrieve all active expenses
public function getAllExpense() {
return $this->join('t_supplierdetailsn', 't_expense.supplier_id = t_supplierdetailsn.SupplierID')
->where('t_expense.isactive', 1)
->orderBy('t_expense.created_on', 'DESC')
->findAll();
}
// Insert new expense
public function insertExpense($data) {
return $this->insert($data) ? $this->insertID() : false;
}
// Get expense by ID
public function getExpenseById($id) {
return $this->where($this->primaryKey, $id)->first(); // Use primary key
}
// Update expense by ID
public function updateExpense($id, $data) {
return $this->update($id, $data); // Use primary key
}
}
?>

View File

@ -304,4 +304,18 @@ GROUP BY financial_year ";
return $r;
}
}
function findEmp($EmpId)
{
$builder = $this->db->table('tbl_users')
->select('tbl_users.*, t_employee_details.*')
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID' ,'left')
->where('tbl_users.EmpID', $EmpId);
$query = $builder->get();
return $query->getResult();
}
}

View File

@ -46,7 +46,7 @@
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
@ -161,7 +161,7 @@
<div class="form-row" style="margin-top:20px">
<div class=" col-md-4">
<label class="col-form-label" for="Bank_Address">Bank Address<span class="badge">*</span></label>
<input type="text" id="bankaddress" name="bankaddress" maxlength="200" class="form-control">
<input type="text" id="bankaddress" name="bankaddress" maxlength="200" class="form-control" required>
</div>
<div class=" col-md-4">
<label for="Cert_BANK">Select Bank Document<br/><small>(only .pdf, .doc, .png, .jpg)</small></label>

View File

@ -12,8 +12,8 @@
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>userListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
@ -21,263 +21,257 @@
<div class="row">
<div class="col-12">
<div class="p-2">
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post">
<div class="box-body">
<!-- Supplier Information -->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="form-row">
<div class=" col-md-3">
<label class="col-form-label" for="EmployeeID">Employee ID</label>
<select class="form-control required select" id="EmpList" name="EmpList">
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post">
<div class="box-body">
<!-- Supplier Information -->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="form-row">
<div class=" col-md-3">
<label class="col-form-label" for="EmployeeID">Employee ID</label>
<select class="form-control required select" id="EmpList" name="EmpList" required>
<option value="">Select Emp ID</option>
<?php
if(!empty($EmpList))
{
foreach ($EmpList as $EID)
{
if (!empty($EmpList)) {
foreach ($EmpList as $EID) {
$EmpID = $EID->EmpID;
// if ($_POST['EmpList'] == $EmpID) {
// echo "<option value=\"".$EmpID."\" selected=\"selected\">".$EmpID.' - '. $EID->FirstName."</option>";
// } else{
echo "<option value=\"".$EmpID."\">".$EmpID.' - '. $EID->FirstName ."</option>";
// }
// if ($_POST['EmpList'] == $EmpID) {
// echo "<option value=\"".$EmpID."\" selected=\"selected\">".$EmpID.' - '. $EID->FirstName."</option>";
// } else{
echo "<option value=\"" . $EmpID . "\">" . $EmpID . ' - ' . $EID->FirstName . "</option>";
// }
}
}
?>
</select>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="FirstName">First Name</label>
<div class="col-md-3">
<label class="col-form-label" for="FirstName">First Name</label>
<input type="text" class="form-control required" readonly id="FirstName" name="FirstName" maxlength="128">
</div>
<div class="col-md-3">
<label class="col-form-label" for="LastName">Last Name</label>
<div class="col-md-3">
<label class="col-form-label" for="LastName">Last Name</label>
<input type="text" class="form-control required" readonly id="LastName" name="LastName" maxlength="128">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Designation">Designation</label>
<input type="text" class="form-control required " readonly id="Designation" name="Designation" maxlength="128">
<label class="col-form-label" for="Designation">Designation</label>
<input type="text" class="form-control required " readonly id="Designation" name="Designation" maxlength="128">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="Emailaddress">Email address</label>
<input type="text" class="form-control required " readonly id="MailID" name="MailID" maxlength="128">
</div>
<div class="col-md-3">
<label for="ContactNumber">Contact Number</label>
<input type="text" class="form-control required digits" readonly id="ContactNo" name="ContactNo" minlength="10"maxlength="10">
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="Emailaddress">Email address</label>
<input type="text" class="form-control required " readonly id="MailID" name="MailID" maxlength="128">
</div>
<div class="col-md-3">
<div class="col-md-3">
<label for="ContactNumber">Contact Number</label>
<input type="text" class="form-control required digits" readonly id="ContactNo" name="ContactNo" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
<label for="Role">Role</label>
<select class="form-control required" id="role" name="role">
<select class="form-control required" id="role" name="role" required>
<option value="0">Select Role</option>
<?php
if(!empty($roles))
{
foreach ($roles as $rl)
{
?>
if (!empty($roles)) {
foreach ($roles as $rl) {
?>
<option value="<?php echo $rl->roleId ?>"><?php echo $rl->role ?></option>
<?php
<?php
}
}
?>
</select>
</select>
</div>
<div class="col-md-3">
<label for="Department">Department</label>
<select class="form-control required" id="role" name="role">
<select class="form-control required" id="Department" name="Department">
<option value="0">Select Department</option>
<?php
if(!empty($departments))
{
foreach ($departments as $dt)
{
?>
if (!empty($departments)) {
foreach ($departments as $dt) {
?>
<option value="<?php echo $dt->departmentId ?>"><?php echo $dt->departments ?></option>
<?php
<?php
}
}
?>
</select>
</select>
</div>
</div>
</div>
<div class="form-row" style="margin-top:20px">
</div>
<div class="form-row" style="margin-top:20px">
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="Password">Password</label>
<input type="password" class="form-control required" id="password" required name="password" maxlength="10">
<label for="Password">Password</label>
<input type="password" class="form-control required" id="password" required name="password" maxlength="10">
</div>
<div class="col-md-3">
<label for="ConfirmPassword">Confirm Password</label>
<input type="password" class="form-control required equalTo" required id="cpassword" name="cpassword" maxlength="10">
<div class="col-md-3">
<label for="ConfirmPassword">Confirm Password</label>
<input type="password" class="form-control required equalTo" required id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
</div>
</div>
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</div>
</form>
</div>
</div>
<?php
$listErrors = session()->getFlashdata('listErrors');
if ($listErrors) {
?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('listErrors'); ?>
</div>
</div>
</div>
<?php
$listErrors = session()->getFlashdata('listErrors');
if($listErrors)
{
?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('listErrors'); ?>
</div>
</div>
</div>
<?php } ?>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end row -->
<?php } ?>
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end row -->
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
</div>
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
<!-- <script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script> -->
<script>
$(document).ready(function() {
$('#EmpList').select2();
$("#EmpList").change(function() {
var empID = $(this).val();
console.log(empID);
if (empID) {
$.ajax({
url: "<?php echo base_url() ?>fetchEmployeeDetails",
type: 'POST',
data: { EmpID: empID },
success: function(data) {
console.log(data);
if (data.success) {
console.log(data.userInfo[0].FirstName);
$("#FirstName").val(data.userInfo[0].FirstName);
$("#LastName").val(data.userInfo[0].LastName);
$("#Designation").val(data.userInfo[0].Designation);
$("#MailID").val(data.userInfo[0].EmailId);
$("#ContactNo").val(data.userInfo[0].ContactNumber);
$("#Department").val(data.userInfo[0].DepartmentName);
} else {
alert('Employee not found');
}
},
error: function() {
alert('Failed to fetch employee details');
}
});
} else {
// Clear fields if no employee ID is selected
$("#FirstName").val('');
$("#LastName").val('');
$("#Designation").val('');
$("#MailID").val('');
$("#ContactNo").val('');
$("#Department").val('');
}
});
});
$('#addPop').click(function() {
if ($('#distriList option:selected').val() != null) {
if ($('#distriList option:selected').val() == 0) {
alert('please select Department');
} else {
var tempSelect = $('#distriList option:selected').val();
var tempText = $('#distriList option:selected').text();
var o = new Option(tempText, tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
var Selectedval = ''
if (orgVal != '') {
Selectedval = orgVal + ':' + hidval;
} else {
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
$(o).html(tempText);
$("#selectDistriList").append(o);
$('#distriList option:selected').remove();
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
tempSelect = '';
tempText = '';
Selectedval = '';
}
} else {
alert("Before add please select any position.");
}
});
</script>
<script>
$('#EmpList').select2();
$('#EmpList').change(function() {
var id = $('#EmpList').val();
var y = <?php echo json_encode($EmpList, JSON_PRETTY_PRINT) ?>;
function Validate() {
var isValid = true;
if(id != "0")
{
$.each(y, function(idx, obj) {
if(obj.EmpID === id)
{
$("#FirstName").val(obj.FirstName);
$("#LastName").val(obj.LastName);
$("#Designation").val(obj.Designation);
$("#Department").val(obj.DepartmentName);
$("#MailID").val(obj.EmailId);
$("#ContactNo").val(obj.ContactNumber);
}
});
}
else
{
alert('Please select Employee Details');
$("#FirstName").val('');
$("#LastName").val('');
$("#Designation").val('');
$("#Department").val('');
$("#MailID").val('');
$("#ContactNo").val('');
return false;
}
});
var fname = document.getElementById('FirstName').value;
if (!fname) {
alert('First Name is required');
isValid = false;
}
var email = document.getElementById('MailID').value;
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailPattern.test(email)) {
alert('Invalid email address');
isValid = false;
}
var password = document.getElementById('password').value;
var cpassword = document.getElementById('cpassword').value;
if (password !== cpassword) {
alert('Passwords do not match');
isValid = false;
}
return isValid;
}
</script>
$('#addPop').click(function ()
{
if ($('#distriList option:selected').val() != null)
{
if($('#distriList option:selected').val()==0 )
{
alert('please select Department');
}
else
{
var tempSelect = $('#distriList option:selected').val();
var tempText = $('#distriList option:selected').text();
var o = new Option(tempText,tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
var Selectedval = ''
if(orgVal != '')
{
Selectedval = orgVal + ':' + hidval;
}
else
{
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
$(o).html(tempText);
$("#selectDistriList").append(o);
$('#distriList option:selected').remove();
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
tempSelect = '';
tempText = '';
Selectedval = '';
}
}
else
{
alert("Before add please select any position.");
}
});
</script>

View File

@ -1,95 +1,93 @@
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"> Add Asset Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="p-2">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"> Add Asset Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="p-2">
<form role="form" id="addAsset" action="<?php echo base_url() ?>addNewasset" method="post">
<div class="box-body">
<!-- Supplier Information -->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="form-row">
<div class="box-body">
<!-- Supplier Information -->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="form-row">
<div class=" col-md-3">
<label class="col-form-label" for="AssetName">Asset Name<span class="badge">*</span></label>
<input type="text" class="form-control " required style="text-transform:uppercase;" id="AssetName" name="AssetName" value="<?php echo isset($_POST['AssetName']) ? $_POST['AssetName'] : '' ?>">
<input type="text" class="form-control " required style="text-transform:uppercase;" id="AssetName" name="AssetName" value="<?php echo isset($_POST['AssetName']) ? $_POST['AssetName'] : '' ?>">
</div>
<div class=" col-md-3">
<label class="col-form-label" for="AssetDescription">Asset Description<span class="badge">*</span></label>
<input type="text" class="form-control required" id="Description" required name="Description" value="<?php echo isset($_POST['Description']) ? $_POST['Description'] : '' ?>">
<input type="text" class="form-control required" id="Description" required name="Description" value="<?php echo isset($_POST['Description']) ? $_POST['Description'] : '' ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Asset User">Asset User<span class="badge">*</span></label>
<input type="text" class="form-control required" required id="User" name="User" value= "<?php echo isset($_POST['User']) ? $_POST['User'] : '' ?>">
<input type="text" class="form-control required" required id="User" name="User" value="<?php echo isset($_POST['User']) ? $_POST['User'] : '' ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetLocation">Asset Location<span class="badge">*</span></label>
<input type="text" class="form-control required" required id="Location" name="Location" value= "<?php echo isset($_POST['Location']) ? $_POST['Location'] : '' ?>">
<input type="text" class="form-control required" required id="Location" name="Location" value="<?php echo isset($_POST['Location']) ? $_POST['Location'] : '' ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3" >
<label for="PurchaseOrderNumber">Purchase Order Number<span class="badge">*</span></label>
<select class="form-control required " required id="PONO" required name="PONO">
<option value="" >Select PO Number</option>
<?php
echo "////***////";
print_r($po);
if(!empty($po))
{
foreach ($po as $po)
{
$PONO = $po->PONO;
// if ($_POST['PONO'] == $PONO)
// {
// echo "<option value=\"".$PONO."\" selected=\"selected\">".$PONO.' - '. $SID->PONO."</option>";
// }
// else
// {
echo "<option value=\"".$PONO."\">".$PONO.' '. $SID->PONO ."</option>";
// }
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="PurchaseOrderNumber">Purchase Order Number<span class="badge">*</span></label>
<select class="form-control required " required id="PONO" required name="PONO">
<option value="">Select PO Number</option>
<?php
echo "////***////";
print_r($po);
if (!empty($po)) {
foreach ($po as $po) {
$PONO = $po->PONO;
// if ($_POST['PONO'] == $PONO)
// {
// echo "<option value=\"".$PONO."\" selected=\"selected\">".$PONO.' - '. $SID->PONO."</option>";
// }
// else
// {
echo "<option value=\"" . $PONO . "\">" . $PONO . "</option>";
// }
}
}
}
?>
</select>
?>
</select>
</div>
<div class="col-md-3">
<label for="SelectMaterialCode">Select Material Code</label>
<div class="col-md-3">
<label for="SelectMaterialCode">Select Material Code</label>
<select class="form-control required select2" required="" id="SelectMaterialCode" name="lineitem">
<option value="-1">Select Material Code</option>
<option value="-1">Select Material Code</option>
</select>
</div>
<div class="col-md-3">
<label for="UOM">UOM</label>
<input type="text" class="form-control required" id="UOM" readonly name="UOM" value="">
<input type="text" class="form-control required" id="UOM" readonly name="UOM" value="">
</div>
<div class="col-md-3">
<label for="Quantity">Quantity</label>
<input type="text" class="form-control required" id="Quantity" name="Quantity" value="">
<input type="text" class="form-control required" id="Quantity" name="Quantity" value="">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="Quantity">Description</label>
<input style="height: 70px;" type="text" class="form-control required" id="PODescription" readonly name="PODescription" value="<?php echo isset($_POST['PODescription']) ? $_POST['PODescription'] : '' ?>">
<input style="height: 70px;" type="text" class="form-control required" id="PODescription" readonly name="PODescription" value="<?php echo isset($_POST['PODescription']) ? $_POST['PODescription'] : '' ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
@ -99,355 +97,337 @@
<input type="text" class="form-control required" id="AssetDept" readonly name="" value="">
</div>
<div class="col-md-3">
<label for="Quantity">Purchase Date</label>
<input id="DateOfPurchase" name="DateOfPurchase" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo isset($_POST['DateOfPurchase']) ? $_POST['DateOfPurchase'] : '' ?>">
<label for="Quantity">Purchase Date<span style="color:red">*</span></label>
<input type="date" id="DateOfPurchase" name="DateOfPurchase" onkeypress="return false;" maxlength="10" class="form-control" value="<?php echo isset($_POST['DateOfPurchase']) ? $_POST['DateOfPurchase'] : '' ?>">
</div>
<div class="col-md-3">
<label for="SupplierName">Supplier Name</label>
<input type="hidden" name="SupplierName" id="SupID">
<input id="SupplierName" readonly name="" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo isset($_POST['SupplierName']) ? $_POST['SupplierName'] : '' ?>">
<input id="SupplierName" readonly name="" onkeypress="return false;" maxlength="10" class="form-control" value="<?php echo isset($_POST['SupplierName']) ? $_POST['SupplierName'] : '' ?>">
</div>
<div class="col-md-3">
<label for="DeliveryDate">Delivery Date</label>
<input id="DeliveryDate" readonly name="DeliveryDate" maxlength="10" class="form-control" >
<input id="DeliveryDate" readonly name="DeliveryDate" maxlength="10" class="form-control">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label for="DateOfCommission">Date Of Commission<span style="color:red">*</span></label>
<input id="DateOfCommission" required name="DateOfCommission" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo isset($_POST['DateOfCommission']) ? $_POST['DateOfCommission'] : '' ?>">
<input type="date" id="DateOfCommission" required name="DateOfCommission" onkeypress="return false;" maxlength="10" class="form-control" value="<?php echo isset($_POST['DateOfCommission']) ? $_POST['DateOfCommission'] : '' ?>">
</div>
<div class="col-md-3">
<label for="AssetValue">Asset Value</label>
<input type="text" class="form-control" id="Assetvalue" name="Assetvalue"onkeypress="return isNumberKey(event)" title="Please Enter currency value" maxlength="255" value= "<?php echo isset($_POST['Assetvalue']) ? $_POST['Assetvalue'] : '' ?>">
</div>
<input type="text" class="form-control" id="Assetvalue" name="Assetvalue" onkeypress="return isNumberKey(event)" title="Please Enter currency value" maxlength="255" value="<?php echo isset($_POST['Assetvalue']) ? $_POST['Assetvalue'] : '' ?>">
</div>
<div class="col-md-3">
<label for="Asset Status">Asset Status</label>
<select class="form-control required select2" required id="AssetStatus" name="AssetStatus">
<option value="" >Select Asset Status</option>
<select class="form-control required select2" required id="AssetStatus" name="AssetStatus">
<option value="">Select Asset Status</option>
<?php
if(!empty($AssetStatus))
{
foreach ($AssetStatus as $SID)
{
if (!empty($AssetStatus)) {
foreach ($AssetStatus as $SID) {
$AssetValue = $SID->ConfigValue;
// if ($_POST['AssetStatus'] == $AssetValue)
// {
// echo "<option value=\"".$AssetValue."\" selected=\"selected\">".$AssetValue."</option>";
// }
// else
// {
echo "<option value=\"".$AssetValue."\">".$AssetValue."</option>";
// }
// if ($_POST['AssetStatus'] == $AssetValue)
// {
// echo "<option value=\"".$AssetValue."\" selected=\"selected\">".$AssetValue."</option>";
// }
// else
// {
echo "<option value=\"" . $AssetValue . "\">" . $AssetValue . "</option>";
// }
}
}
?>
</select>
</select>
</div>
<div class="col-md-3">
<label for="Remarks">Remarks</label>
<input type="text" class="form-control required" id="Remarks" name="Remarks" maxlength="500" value= "<?php echo isset($_POST['Remarks']) ? $_POST['Remarks'] : '' ?>">
<input type="text" class="form-control required" id="Remarks" name="Remarks" maxlength="500" value="<?php echo isset($_POST['Remarks']) ? $_POST['Remarks'] : '' ?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<input type="checkbox" id="isactive" name="isactive" <?php echo (isset($_POST['isactive']) ? 'checked' : '') ?>> <label for="">IsActive</label>
<input type="checkbox" id="isactive" name="isactive" <?php echo (isset($_POST['isactive']) ? 'checked' : '') ?>> <label for="">IsActive</label>
</div>
</div>
</div>
<div class="col-md-12 text-right">
</div>
</div>
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</div>
</form>
</div>
</div>
<?php
$listErrors = session()->getFlashdata('listErrors');
if($listErrors)
{
?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('listErrors'); ?>
</div>
</div>
</div>
</form>
</div>
</div>
<?php } ?>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
$listErrors = session()->getFlashdata('listErrors');
if ($listErrors) {
?>
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('listErrors'); ?>
</div>
</div>
</div>
<?php } ?>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end row -->
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
<?php } ?>
<!-- end row -->
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
</div>
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
<script>
$('#PONO').on('change',function(){
var PONO = $(this).val();
$('#SupplierName').val('');
$('#SupID').val('');
$('#MaterialCode').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#depcode').val('');
$('#AssetDept').val('');
$('#DateOfPurchase').val('');
$('#DeliveryDate').val('');
$('#PODescription').val('');
$('#Assetvalue').val('');
// alert(PONO);
if(PONO){
$.ajax({
type:'POST',
url:"<?php echo base_url() ?>assetdetails/getpodetails",
data:'PONO='+PONO,
dataType: 'json',
success:function(data){
//alert(data);
var line ='';
$('#PONO').on('change', function() {
var PONO = $(this).val();
$('#SupplierName').val('');
$('#SupID').val('');
$('#MaterialCode').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#depcode').val('');
$('#AssetDept').val('');
$('#DateOfPurchase').val('');
$('#DeliveryDate').val('');
$('#PODescription').val('');
$('#Assetvalue').val('');
// alert(PONO);
if (PONO) {
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getpodetails",
data: 'PONO=' + PONO,
dataType: 'json',
success: function(data) {
//alert(data);
var line = '';
$('#SelectMaterialCode').empty();
//alert('before');
$.each(data, function (i, item) {
//alert(item);
$.each(data, function(i, item) {
//alert(item);
//line ='<option>select Material Code</option>';
//line ='<option>select Material Code</option>';
//line +='<option value='+item.LineItemNo+'>'+item.LineItemNo+'-'+item.MaterialCode+'</option>';
//$('#DeliveryDate').val(item.DeliveryDate);
line+=item;
$('#SelectMaterialCode').append(line);
//$('#DeliveryDate').val(item.DeliveryDate);
line += item;
$('#SelectMaterialCode').append(line);
});
}
});
}
});
}
});
$('#SelectMaterialCode').on('change',function(){
var line = $(this).val();
});
$('#SelectMaterialCode').on('change', function() {
var line = $(this).val();
//line +='<option>select Material Code</option>'
if(line){
$.ajax({
type:'POST',
url:"<?php echo base_url() ?>assetdetails/getline",
data:'line='+line,
success:function(data){
// alert(data);
var id = $('#SelectMaterialCode').val();
$.each(JSON.parse(data), function (i, item) {
if(id == item.LineItemNo){
$('#DateOfPurchase').val(item.PODate);
if(item.DeliveryDate != null )
{
var date = new Date(item.DeliveryDate);
var date1 = (date.getDate()+ '-' + (date.getMonth() + 1)+ '-' + date.getFullYear());
if(item.DeliveryDate == '0000-00-00' || item.DeliveryDate == '30-11--0001')
{
$('#DeliveryDate').val('');
}
else
{
//alert(item.DeliveryDate+ ',' + date1);
$("#DeliveryDate").val(date1);
}
if (line) {
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getline",
data: 'line=' + line,
success: function(data) {
// alert(data);
//var correctDate = [DDate.getDate(),DDate.getMonth()+1,DDate.getFullYear()].join("/");
//alert(correctDate);
var id = $('#SelectMaterialCode').val();
$.each(JSON.parse(data), function(i, item) {
if (id == item.LineItemNo) {
}
else
{
$('#DeliveryDate').val('');
}
$('#SupplierName').val(item.SupplierName);
$('#SupID').val(item.SupplierID);
$('#MaterialCode').val(item.MaterialCode);
$('#UOM').val(item.UOM);
$('#Quantity').val(item.Quantity);
$('#depcode').val(item.Departmentcode);
$('#AssetDept').val(item.DepartmentName);
$('#PODescription').val(item.MaterialName);
//alert(item.TotalValue);
$('#Assetvalue').val(item.TotalValue);
var date = new Date(item.PODate);
var date3 = (date.getDate()+ '-' + (date.getMonth() + 1)+ '-' + date.getFullYear());
$("#DateOfPurchase").val(date3);
}
//line ='<option>'+item.LineItemNo+'</option>';
// $('#POLineItem').append(line);
});
}
});
$('#DateOfPurchase').val(item.PODate);
if (item.DeliveryDate != null) {
var date = new Date(item.DeliveryDate);
var date1 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
if (item.DeliveryDate == '0000-00-00' || item.DeliveryDate == '30-11--0001') {
$('#DeliveryDate').val('');
} else {
//alert(item.DeliveryDate+ ',' + date1);
$("#DeliveryDate").val(date1);
}
//var correctDate = [DDate.getDate(),DDate.getMonth()+1,DDate.getFullYear()].join("/");
//alert(correctDate);
} else {
$('#DeliveryDate').val('');
}
$('#SupplierName').val(item.SupplierName);
$('#SupID').val(item.SupplierID);
$('#MaterialCode').val(item.MaterialCode);
$('#UOM').val(item.UOM);
$('#Quantity').val(item.Quantity);
$('#depcode').val(item.Departmentcode);
$('#AssetDept').val(item.DepartmentName);
$('#PODescription').val(item.MaterialName);
//alert(item.TotalValue);
$('#Assetvalue').val(item.TotalValue);
var date = new Date(item.PODate);
var date3 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
$("#DateOfPurchase").val(date3);
}
//line ='<option>'+item.LineItemNo+'</option>';
// $('#POLineItem').append(line);
});
}
});
}
});
function validate()
{
if($("#AssetName").val().length <1)
{
alert('Please Enter the AssetName');
$("#AssetName").focus();
return false;
}
if($('#Description').val().length <1)
{
alert('Please Enter the Asset Description');
$("#Description").focus();
return false;
});
function validate() {
if ($("#AssetName").val().length < 1) {
alert('Please Enter the AssetName');
$("#AssetName").focus();
return false;
}
if ($('#Description').val().length < 1) {
alert('Please Enter the Asset Description');
$("#Description").focus();
return false;
}
if ($('#User').val().length < 1) {
alert('Please Enter the Asset User');
$("#User").focus();
return false;
}
if ($('#Location').val().length < 1) {
alert('Please Enter the Asset Location');
$("#Location").focus();
return false;
}
if ($("#PONO option:selected").val() == "") {
alert('Please Select PO Number ');
$("#PONO").focus();
return false;
}
if ($("option:selected", $("#SelectMaterialCode")).val() == '-1') {
alert('Please Select MaterialCode');
return false;
}
if ($('#DateOfCommission').val().length < 1) {
alert('Please Enter the DateOfCommission');
$("#DateOfCommission").focus();
return false;
}
if ($("option:selected", $("#AssetStatus")).val() == '-1') {
alert('Please Select AssetStatus');
return false;
}
}
if($('#User').val().length <1)
{
alert('Please Enter the Asset User');
$("#User").focus();
return false;
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear();
var SIAStartYear = year - 2015;
var mindt = year - 70;
var maxdt = year - 15;
// $("#PONO").select2();
// $("#SelectMaterialCode").select2();
//$("#AssetStatus").select2();
$("#DateOfCommission").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
});
$("#DateOfPurchase").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
});
});
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
return true;
}
if($('#Location').val().length <1)
{
alert('Please Enter the Asset Location');
$("#Location").focus();
return false;
}
if($("#PONO option:selected").val() == "")
{
alert('Please Select PO Number ');
$("#PONO").focus();
return false;
}
if($("option:selected", $("#SelectMaterialCode")).val() == '-1')
{
alert('Please Select MaterialCode');
return false;
}
if($('#DateOfCommission').val().length <1)
{
alert('Please Enter the DateOfCommission');
$("#DateOfCommission").focus();
return false;
}
if($("option:selected", $("#AssetStatus")).val() == '-1')
{
alert('Please Select AssetStatus');
return false;
}
}
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear() ;
var SIAStartYear = year - 2015;
var mindt = year-70;
var maxdt = year-15;
// $("#PONO").select2();
// $("#SelectMaterialCode").select2();
//$("#AssetStatus").select2();
$("#DateOfCommission").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
});
$("#DateOfPurchase").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
});
});
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>

View File

@ -1,81 +1,82 @@
<style>
th{
th {
background-color: #ddd;
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"> Add Config Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>configlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="adddepartment" action="<?php echo base_url() ?>savedepartment" method="post">
<div class="form-row" style="margin-top:10px">
<div class=" col-md-3">
<label class="col-form-label" for="ConfigurationName">Configuration Name</label>
<?php
$data = array('name' => 'configurationname', 'value' => set_value('configurationname'), 'id' => 'configurationname', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data); ?>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class=" col-md-3">
<label class="col-form-label" for="Comments">Comments</label>
<?php
$data = array('name' => 'Comments', 'value' => set_value('Comments'), 'id' => 'Comments', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data);
?>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12 text-right">
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Configuration</a>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12">
<table id="configtable" class="table table-bordered table-hover responsive-utilities jambo_table" style="background-color:#fff;font-size:12px;" >
<thead>
<th>S.NO</th>
<th>Configuration Value</th>
<th>Action</th>
</thead>
<tbody id="tempAppend">
<!--<tr>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"> Add Config Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>configlisting"><span class="bold">Back</span></a>
</div>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="addconfig" action="<?php echo base_url() ?>configurationctrl/saveconfig" method="post">
<div class="form-row" style="margin-top:10px">
<div class=" col-md-3">
<label class="col-form-label" for="ConfigurationName">Configuration Name</label>
<?php
$data = array('name' => 'configurationname', 'value' => set_value('configurationname'), 'id' => 'configurationname', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data); ?>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class=" col-md-3">
<label class="col-form-label" for="Comments">Comments</label>
<?php
$data = array('name' => 'Comments', 'value' => set_value('Comments'), 'id' => 'Comments', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data);
?>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12 text-right">
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Configuration</a>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12">
<table id="configtable" class="table table-bordered table-hover responsive-utilities jambo_table" style="background-color:#fff;font-size:12px;">
<thead>
<th>S.NO</th>
<th>Configuration Value</th>
<th>Action</th>
</thead>
<tbody id="tempAppend">
<!--<tr>
<td>001</td>
<td>100</td>
@ -84,127 +85,127 @@
<a><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>-->
</tbody>
</tbody>
</table>
<input type="hidden" name="newhidden" id="newhidden" />
</div>
</table>
<input type="hidden" name="newhidden" id="newhidden" />
</div>
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</form>
</div>
<!-- end row -->
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
<input type="submit" onclick="return Validate();" value="Submit" class="btn btn-success">
</div>
</form>
</div>
<!-- end row -->
</div>
</div> <!-- end card -->
</div><!-- end col -->
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
</div>
t <!-- end row -->
</div> <!-- container -->
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
</div>
t <!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Add Configuration</center>
</h4>
</div>
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Add Configuration</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<input class="form-control" name="ConfigValue" class="form-control" id="ConfigValue" type="text">
<input class="form-control" name="ConfigValue" class="form-control" id="ConfigValue" type="text">
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickAdd" ID="tempClickAdd" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
</div>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickAdd" ID="tempClickAdd" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
</div>
</div>
</div>
</div>
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Edit Configuration</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'EditConfigValue', 'value' => set_value('EditConfigValue'), 'id' => 'EditConfigValue', 'class' => 'form-control');
echo form_input($data);
?>
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Edit Configuration</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'EditConfigValue', 'value' => set_value('EditConfigValue'), 'id' => 'EditConfigValue', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
</div>
</div>
</div>
</div>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
@ -376,5 +377,4 @@
}
}
</script>
</script>

View File

@ -20,7 +20,7 @@
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>departmentListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
<a class="btn btn-cancel" href="<?php echo base_url(); ?>departmentListing"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->

View File

@ -469,7 +469,7 @@ function ValidateUA() {
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->

View File

@ -39,22 +39,22 @@
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Configuration Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-success" href="<?php echo base_url(); ?>addconfig">Add New Configuration</a>
</div>
</div>
<?php
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Configuration Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-success" href="<?php echo base_url(); ?>addconfig">Add New Configuration</a>
</div>
</div>
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
@ -74,73 +74,73 @@
</div>
<?php } ?>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="config_list_table" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Create Date</th>
<th>Configuration ID</th>
<th>Configuration Name</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($userRecords)) {
foreach ($userRecords as $record) {
?>
<tr>
<?php if (date('d-m-Y', strtotime($record->CreatedDate)) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
$cdate = date('d-m-Y', strtotime($record->CreatedDate));
} ?>
<td align="right"><?php echo $cdate; ?> </td>
<td><?php echo $record->Config_ID ?></td>
<td><?php echo $record->ConfigName ?></td>
<td><?php echo $record->Comments ?> </td>
<!-- <td><?php echo $record->CreatedDate ?></td> -->
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="config_list_table" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Create Date</th>
<th>Configuration ID</th>
<th>Configuration Name</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($userRecords)) {
foreach ($userRecords as $record) {
?>
<tr>
<?php if (date('d-m-Y', strtotime($record->CreatedDate)) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
$cdate = date('d-m-Y', strtotime($record->CreatedDate));
} ?>
<td align="right"><?php echo $cdate; ?> </td>
<td><?php echo $record->Config_ID ?></td>
<td><?php echo $record->ConfigName ?></td>
<td><?php echo $record->Comments ?> </td>
<!-- <td><?php echo $record->CreatedDate ?></td> -->
<!-- <td align="right"><?php $dt = new DateTime($record->CreatedDate);
$CreatedDate = $dt->format('d-m-Y');
echo $CreatedDate ?> </td> -->
<!-- <td align="right"><?php $dt = new DateTime($record->CreatedDate);
$CreatedDate = $dt->format('d-m-Y');
echo $CreatedDate ?> </td> -->
<td><a href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"><i class="fa fa-pencil"></i>&nbsp;&nbsp;&nbsp;</a>
<!-- <a><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a> -->
</td>
<td><a href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"><i class="fas fa-pencil-alt"></i>&nbsp;&nbsp;&nbsp;</a>
<!-- <a><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a> -->
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</tr>
<?php
}
}
?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
</section>
@ -171,78 +171,83 @@
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
// Initialize the DataTable
var table = $('#config_list_table').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
responsive: true, // Responsive table
order: [[0, 'desc']], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
order: [
[0, 'desc']
], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
// Return true if the date is within the range
return date >= startDate && date <= endDate;
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
});
});
</script>

View File

@ -38,244 +38,115 @@ if(!empty($EmpList))
?>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Edit User <?= ' - '.$EmpId; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>userListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section><br>
<section class="content">
<br/>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div id="content"></div>
<div class="box box-success">
<!-- form start -->
<form role="form" action="<?php echo base_url() ?>editUser" method="post" id="editUser" role="form">
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="fname">Employee ID</label>
<input type="text" class="form-control required" value="<?php echo $EmpId ?>" readonly id="EmpList" name="EmpList" maxlength="128">
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit User <?= ' - '.$EmpId; ?> Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>userListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" action="<?php echo base_url() ?>editUser" method="post" id="editUser">
<div class="box-body">
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="EmpList">Employee ID</label>
<input type="text" class="form-control required" value="<?php echo $EmpId ?>" readonly id="EmpList" name="EmpList" maxlength="128">
</div>
<div class="col-md-3">
<label class="col-form-label" for="FirstName">First Name</label>
<input type="text" class="form-control required" value="<?php echo $FirstName ?>" readonly id="FirstName" name="FirstName" maxlength="128">
</div>
<div class="col-md-3">
<label class="col-form-label" for="LastName">Last Name</label>
<input type="text" class="form-control required" value="<?php echo $LastName ?>" readonly id="LastName" name="LastName" maxlength="128">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Designation">Designation</label>
<input type="text" class="form-control required" value="<?php echo $Designation ?>" readonly id="Designation" name="Designation" maxlength="128">
</div>
</div>
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="Department">Department</label>
<input type="text" class="form-control required" value="<?php echo $Department ?>" readonly id="Department" name="Department" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
<label for="MailID">Email address</label>
<input type="text" class="form-control required email" value="<?php echo $EmailId ?>" readonly id="MailID" name="MailID" maxlength="128">
</div>
<div class="col-md-3">
<label for="ContactNo">Contact Number</label>
<input type="text" class="form-control required digits" value="<?php echo $ContactNo ?>" readonly id="ContactNo" name="ContactNo" minlength="10" maxlength="10">
</div>
<div class="col-md-3">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" required name="password" maxlength="10">
</div>
</div>
<div class="form-row">
<div class="col-md-3">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control equalTo" id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="fname">First Name</label>
<input type="text" class="form-control required" value="<?php echo $FirstName ?>" readonly id="FirstName" name="FirstName" maxlength="128">
</div>
<div class="form-group text-right mt-3">
<input type="hidden" name="txtSelectedDepartment" id="txtSelectedDepartment">
<input type="hidden" name="txtEmpid" id="txtEmpid" value="<?php echo $EmpId ?>">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white;margin-right: 15px;" value="Reset">
<input type="submit" class="btn btn-success" value="Submit">
</div>
<div class="col-md-2">
<div class="form-group">
<label for="fname">Last Name</label>
<input type="text" class="form-control required" value="<?php echo $LastName ?>" readonly id="LastName" name="LastName" maxlength="128">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="email">Designation</label>
<input type="text" class="form-control required " value="<?php echo $Designation ?>" readonly id="Designation" name="Designation" maxlength="128">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="mobile">Department</label>
<input type="text" class="form-control required" value="<?php echo $Department ?>" readonly id="Department" name="Department" minlength="10"maxlength="10">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="email">Email address</label>
<input type="text" class="form-control required email" value="<?php echo $EmailId ?>" readonly id="MailID" name="MailID" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="mobile">Contact Number</label>
<input type="text" class="form-control required digits" value="<?php echo $ContactNo ?>" readonly id="ContactNo" name="ContactNo" minlength="10"maxlength="10">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" required name="password" maxlength="10">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control equalTo" id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="display:none;">
<label for="role">Role</label>
<select class="form-control required" id="role" name="role">
<option value="<?php echo $Role ?>"><?php echo $RoleName ?></option>
<?php
if(!empty($roles))
{
foreach ($roles as $rl)
{
?>
<option value="<?php echo $rl->roleId ?>"><?php echo $rl->role ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="col-md-4">
<label>Department</label>
<div>
</form>
<?php
$options = array("0"=>'Select Department',
"1"=>'System Administrator');
// print_r($Departmentlist);
if(!empty($Departmentlist))
{
foreach ($Departmentlist as $SID):
$options[$SID->DEPCode] = $SID->DEPCode.' '.' - '.' '.$SID->DepartmentName;
endforeach;
}
echo form_multiselect('distriList', $options,set_value('distriList', array()),'id="distriList"' ,'class="form-control required"','required="true"');
?>
$listErrors = session()->getFlashdata('listErrors');
if ($listErrors) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('listErrors'); ?>
</div>
<?php } ?>
<?php
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
</div>
</div>
<div class="col-md-4">
<center>
<a style="color:white" href="javascript:void(0);" id="addPop"><button type="button" style="margin: 30px 0px 0px 15px;" class="btn btn-success">Add</button></a><br>
<a style="color:white" href="javascript:void(0);" id="removePop"><button type="button" style="margin: 10px 0px 0px 15px;" class="btn btn-success">Remove</button></a><br>
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
</center>
</div>
<div class="col-md-4">
<b>&nbsp;</b>
<?php
$option["0"] = 'Selected Department';
//print_r($AccessDept);
if(!empty($AccessDept))
{
foreach ($AccessDept as $SID):
if($SID->AssDep == '1')
{
$option[$SID->AssDep] = "01-System Administrator";
}
else
{
$option[$SID->AssDep] = $SID->AssDep.' '.' - '.' '.$SID->DepartmentName;
}
endforeach;
}
echo form_multiselect('selectDistriList[]', $option,set_value('selectDistriList[]', array()),'id="selectDistriList"','size="10"');
?>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<input type="hidden" name="txtSelectedDepartment" id="txtSelectedDepartment" />
<input type="hidden" name="txtEmpid" id="txtEmpid" value="<?php echo $EmpId?>" />
<input type="reset" class="btn btn-cancel" value="Cancel" />
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?> </div>
</div>
</div>
</section>
</div>
<script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script>

View File

@ -11,81 +11,72 @@ $DateOfPurchase = '';
$DateOfCommison = '';
$AssetValue = '';
$AssetStatus = '';
$IsActive ='';
$IsActive = '';
$Remarks = '';
$DepartmentName ='';
$Department ='';
$DepartmentName = '';
$Department = '';
$SupplierCode = '';
$MaterialCode = '';
$PONO = '';
$POLineItem='';
$Quantity='';
$POLineItem = '';
$Quantity = '';
$UOM = '';
$MaterialName='';
$DeliveryDate='';
$MaterialName = '';
$DeliveryDate = '';
$DDate = '';
if(!empty($assetList))
{
foreach ($assetList as $Asset)
{
//print_r($Asset);die();
$AssetCode = $Asset->AssetCode;
$AssetName = $Asset->AssetName;
$Description = $Asset->Description;
if (!empty($assetList)) {
foreach ($assetList as $Asset) {
//print_r($Asset);die();
$AssetCode = $Asset->AssetCode;
$AssetName = $Asset->AssetName;
$Description = $Asset->Description;
$Department = $Asset->DEPCode;
$DepartmentName = $Asset->DepartmentName;
$Location = $Asset->Location;
$User = $Asset->UserName;
$SupplierName = $Asset->SupplierName;
$Location = $Asset->Location;
$User = $Asset->UserName;
$SupplierName = $Asset->SupplierName;
$SupplierCode = $Asset->SupplierCode;
$DateOfPurchase = $Asset->DateOfPurchase;//print_r($Asset->DateOfPurchase);
if($DateOfPurchase != '' && $DateOfPurchase != '0000-00-00 00:00:00' ) {
$PODate = new DateTime($DateOfPurchase);
$DateOfPurchase = $PODate->format('d-m-Y');
}
else {
$DateOfPurchase = '';
}
$DateOfCommison = $Asset->DateOfCommison;
if($DateOfCommison != '' && $DateOfCommison != '0000-00-00 00:00:00' ) {
$DateOfCommission= new DateTime($Asset->DateOfCommison, new DateTimeZone('Asia/Kolkata'));
$DateOfCommison = $DateOfCommission->format('d-m-Y');
}
else {
$DateOfCommison = '';
}
$DateOfPurchase = $Asset->DateOfPurchase; //print_r($Asset->DateOfPurchase);
if ($DateOfPurchase != '' && $DateOfPurchase != '0000-00-00 00:00:00') {
$PODate = new DateTime($DateOfPurchase);
$DateOfPurchase = $PODate->format('d-m-Y');
} else {
$DateOfPurchase = '';
}
$DateOfCommison = $Asset->DateOfCommison;
if ($DateOfCommison != '' && $DateOfCommison != '0000-00-00 00:00:00') {
$DateOfCommission = new DateTime($Asset->DateOfCommison, new DateTimeZone('Asia/Kolkata'));
$DateOfCommison = $DateOfCommission->format('d-m-Y');
} else {
$DateOfCommison = '';
}
$AssetValue = $Asset->AssetValue;
$AssetStatus = $Asset->AssetStatus;
$MaterialCode = $Asset->MaterialCode;
$PONO = $Asset->PONO;
$POLineItem = $Asset->POLineItem;
$Quantity = $Asset->Quantity;
$MaterialName = $Asset->MaterialName;
$UOM = $Asset->UOM;
$DDt = $Asset->DeliveryDate;
if($DDt != '' && $DDt != '0000-00-00 00:00:00'){
$DDate = new DateTime($DDt, new DateTimeZone('Asia/Kolkata'));
$DeliveryDate = $DDate->format('d-m-Y');
}
else
{
$DeliveryDate = '';
}
$AssetStatus = $Asset->AssetStatus;
$MaterialCode = $Asset->MaterialCode;
$PONO = $Asset->PONO;
$POLineItem = $Asset->POLineItem;
$Quantity = $Asset->Quantity;
$MaterialName = $Asset->MaterialName;
$UOM = $Asset->UOM;
$DDt = $Asset->DeliveryDate;
if ($DDt != '' && $DDt != '0000-00-00 00:00:00') {
$DDate = new DateTime($DDt, new DateTimeZone('Asia/Kolkata'));
$DeliveryDate = $DDate->format('d-m-Y');
} else {
$DeliveryDate = '';
}
$Remarks = $Asset->Remarks;
$Remarks = $Asset->Remarks;
$chk = $Asset->IsActive;
if($chk == 1)
{
$IsActive = 'checked';
}
else
{
$IsActive = '';
}
if ($chk == 1) {
$IsActive = 'checked';
} else {
$IsActive = '';
}
// if($DateOfPurchase != '')
// {
// $dtpurchase = new DateTime($DateOfPurchase);
@ -96,479 +87,322 @@ if(!empty($assetList))
// $dtCommission = new DateTime($DateOfCommission);
// $DOCommission = $dtCommission ->format('Y-m-d');
// }
}
}
}
?>
<script>
<script>
$(function() {
var d = new Date();
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear();
var SIAStartYear = year - 2015;
var mindt = year - 70;
var maxdt = year - 15;
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear() ;
var SIAStartYear = year - 2015;
var mindt = year-70;
var maxdt = year-15;
// $("#PONO").select2();
// $("#SelectMaterialCode").select2();
// $("#AssetStatus").select2();
$("#DateOfCommission").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
// $("#PONO").select2();
// $("#SelectMaterialCode").select2();
// $("#AssetStatus").select2();
$("#DateOfCommission").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
});
$("#DateOfPurchase").datepicker({
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,
});
$("#DateOfPurchase").datepicker({
minDate: new Date(year - SIAStartYear, 1, 1),
maxDate: 'now',
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
});
});
});
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
});
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center> Edit Asset Details-<?php echo $AssetCode ; ?></center>
</h1>
</section>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url()?>assetListing" class="btn btn-success"value="Back">Back</a>
</div>
<br>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-success">
<!-- form start -->
<form role="form" id="addAsset" action="<?php echo base_url() ?>editasset" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Asset_Name">Asset Name</span><span style="color:red">*</span>
</b>
<input type="text" class="form-control required" id="AssetName" name="AssetName" value="<?php echo $AssetName;?>" style="text-transform:uppercase;">
<input type="hidden" name="AssetCode" id="AssetCode" class="form-control" readonly value="<?php echo $AssetCode;?>">
<div class="content-page">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Asset Details - <?php echo $AssetCode; ?></h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing"><span class="bold">Back</span></a>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="addAsset" action="<?php echo base_url() ?>editasset" method="post">
<div class="form-row">
<div class="col-md-3">
<label for="AssetName">Asset Name <span class="badge">*</span></label>
<input type="text" class="form-control" id="AssetName" name="AssetName" value="<?php echo $AssetName; ?>" style="text-transform:uppercase;" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Description">Asset Description</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="Description" name="Description"
value="<?php echo $Description; ?>">
<div class="col-md-3">
<label for="Description">Asset Description <span class="badge">*</span></label>
<input type="text" class="form-control" id="Description" name="Description" value="<?php echo $Description; ?>" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="AssetOwner">Asset User</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="User" name="User" value="<?php echo $User;?>">
<div class="col-md-3">
<label for="User">Asset User <span class="badge">*</span></label>
<input type="text" class="form-control" id="User" name="User" value="<?php echo $User; ?>" required>
</div>
<div class="col-md-3">
<label for="Location">Asset Location <span class="badge">*</span></label>
<input type="text" class="form-control" id="Location" name="Location" value="<?php echo $Location; ?>" required>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Location">Asset Location</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="Location" name="Location"
value="<?php echo $Location;?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b>
<span for="PONO">Purchase Order Number</span><span style="color:red">*</span></b>
<select class="form-control required select2" id="PONO" name="PONO">
<option value="<?php echo $PONO;?>"><?php echo $PONO;?></option>
<?php
if(!empty($PO))
{
foreach ($PO as $po)
{
$PONO1 = $po->PONO;
if(trim($PONO1) != trim($PONO))
{
if ($_POST['PONO'] == $PONO1)
{
echo "<option value=\"".$PONO1."\" selected=\"selected\">". $po->PONO."</option>";
}
else
{
echo "<option value=\"".$PONO1."\">". $po->PONO ."</option>";
}
}
<div class="form-row mt-3">
<div class="col-md-3">
<label for="PONO">Purchase Order Number <span class="badge">*</span></label>
<select class="form-control select2" id="PONO" name="PONO" required>
<option value="<?php echo $PONO; ?>"><?php echo $PONO; ?></option>
<?php if (!empty($PO)) {
foreach ($PO as $po) {
$PONO1 = $po->PONO;
if (trim($PONO1) != trim($PONO)) {
echo "<option value=\"" . $PONO1 . "\">" . $PONO1 . "</option>";
}
}
?>
</select>
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group">
<b>
<span for="SelectMaterialCode" value=""> select Material Code</span>
</b>
<select class="form-control required select2" id="SelectMaterialCode" name="lineitem">
<option value="<?php echo $POLineItem;?>"><?php echo $POLineItem;?></option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<b>
<span for="MaterialCode">Material Code</span></b>
<input type="text" class="form-control required" id="MaterialCode" readonly name="MaterialCode" value="<?php echo $MaterialCode;?>">
</div>
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group">
<b>
<span for="UOM">UOM</span></b>
<input type="text" class="form-control required" id="UOM"value="<?php echo $UOM;?>"readonly name="UOM" value="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<b>
<span for="Quantity">Quantity</span></b>
<input type="text" class="form-control required" id="Quantity" value="<?php echo $Quantity;?>" name="Quantity" value="">
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Description">Description</span></b>
<input type="text" class="form-control required" id="PODescription" readonly name="PODescription" value="<?php echo $MaterialName;?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<input type="hidden" name="AssetDept" id="depcode" value="<?php echo $Department?>">
<b>
<span for="AssetDept">Asset Department</span></b>
<input type="text" class="form-control required" value="<?php echo $DepartmentName;?>" id="AssetDept" readonly>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="DateOfPurchase">Purchase Date</span></b>
<input id="DateOfPurchase" required name="DateOfPurchase" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $DateOfPurchase;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="DateOfPurchase">Supplier Name</span></b>
<input type="hidden" name="SupplierName" id="SupID" value="<?php echo $SupplierCode;?>">
<input id="SupplierName" readonly onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $SupplierName; ?>">
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group"><b>
<span for="DeliveryDate">Delivery Date</span></b>
<input id="DeliveryDate" readonly name="DeliveryDate" maxlength="10" class="form-control" value= "<?php echo $DeliveryDate;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group"><b>
<span for="DateOfCommission">Date Of Commission</span></b>
<input id="DateOfCommission" required name="DateOfCommission" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $DateOfCommison;?>">
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group"><b>
<span for="Assetvalue">Asset Value</span>
</b> <input type="text" class="form-control required" id="Assetvalue" name="Assetvalue" onkeypress="return isNumberKey(event)" maxlength="255" value="<?php echo $AssetValue;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group"><b>
<span for="AssetStatus">Asset Status</span></b>
<select class="form-control required" id="AssetStatus" name="AssetStatus">
<option value="<?php echo $AssetStatus; ?>"><?php echo $AssetStatus; ?></option>
<?php
if(!empty($AssetStatusList))
{
foreach ($AssetStatusList as $SID)
{
?>
<option value="<?php echo $SID->ConfigValue; ?>"> <?php echo $SID->ConfigValue ?></option>
<?php
}
}
?>
} ?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group"><b>
<span for="Remarks">Remarks</span>
</b>
<input type="text" class="form-control required" id="Remarks" name="Remarks" maxlength="500" value="<?php echo $Remarks; ?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive ?> > IsActive
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<input type="submit" class="btn btn-success" value="Submit" />
<a href="<?php echo base_url()?>assetListing" class="btn btn-success" id="cancel" value="Cancel">Cancel</a>
</div>
<div class="col-md-3">
<label for="SelectMaterialCode">Select Material Code</label>
<select class="form-control select2" id="SelectMaterialCode" name="lineitem">
<option value="<?php echo $POLineItem; ?>"><?php echo $POLineItem; ?></option>
</select>
</div>
<div class="col-md-3">
<label for="UOM">UOM</label>
<input type="text" class="form-control" id="UOM" name="UOM" value="<?php echo $UOM; ?>" readonly>
</div>
<div class="col-md-3">
<label for="Quantity">Quantity</label>
<input type="text" class="form-control" id="Quantity" name="Quantity" value="<?php echo $Quantity; ?>">
</div>
</div>
<div class="form-row mt-3">
<div class="col-md-3">
<label for="PODescription">Description</label>
<input type="text" class="form-control" id="PODescription" name="PODescription" value="<?php echo $MaterialName; ?>" readonly>
</div>
<div class="col-md-3">
<label for="AssetDept">Asset Department</label>
<input type="text" class="form-control" id="AssetDept" name="AssetDept" value="<?php echo $DepartmentName; ?>" readonly>
</div>
<div class="col-md-3">
<label for="DateOfPurchase">Purchase Date</label>
<input type="text" class="form-control" id="DateOfPurchase" name="DateOfPurchase" value="<?php echo $DateOfPurchase; ?>" required onkeypress="return false;">
</div>
<div class="col-md-3">
<label for="SupplierName">Supplier Name</label>
<input type="text" class="form-control" id="SupplierName" name="SupplierName" value="<?php echo $SupplierName; ?>" readonly>
</div>
</div>
<div class="form-row mt-3">
<div class="col-md-3">
<label for="DeliveryDate">Delivery Date</label>
<input type="text" class="form-control" id="DeliveryDate" name="DeliveryDate" value="<?php echo $DeliveryDate; ?>" readonly>
</div>
<div class="col-md-3">
<label for="DateOfCommission">Date Of Commission <span class="badge">*</span></label>
<input type="text" class="form-control" id="DateOfCommission" name="DateOfCommission" value="<?php echo $DateOfCommison; ?>" required onkeypress="return false;">
</div>
<div class="col-md-3">
<label for="AssetValue">Asset Value</label>
<input type="text" class="form-control" id="Assetvalue" name="Assetvalue" value="<?php echo $AssetValue; ?>" onkeypress="return isNumberKey(event)" maxlength="255">
</div>
<div class="col-md-3">
<label for="AssetStatus">Asset Status</label>
<select class="form-control select2" id="AssetStatus" name="AssetStatus">
<option value="<?php echo $AssetStatus; ?>"><?php echo $AssetStatus; ?></option>
<?php if (!empty($AssetStatusList)) {
foreach ($AssetStatusList as $SID) {
echo "<option value=\"" . $SID->ConfigValue . "\">" . $SID->ConfigValue . "</option>";
}
} ?>
</select>
</div>
</div>
<div class="form-row mt-3">
<div class="col-md-3">
<label for="Remarks">Remarks</label>
<input type="text" class="form-control" id="Remarks" name="Remarks" value="<?php echo $Remarks; ?>" maxlength="500">
</div>
<div class="col-md-3">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="isactive" name="isactive" <?php echo $IsActive ? 'checked' : ''; ?>>
<label class="form-check-label" for="isactive">Is Active</label>
</div>
</div>
</div>
<div class="form-row mt-4 text-right">
<div class="col-md-12">
<button type="submit" class="btn btn-success">Submit</button>
<a href="<?php echo base_url() ?>assetListing" class="btn btn-cancel">Cancel</a>
</div>
</div>
</form>
</div>
</div>
</form>
</div>
<div class="col-md-4">
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?> </div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
<script>
<script>
$('#PONO').on('change', function() {
$('#PONO').on('change',function(){
var PONO = $(this).val();
$('#SupplierName').val('');
$('#SupID').val('');
$('#MaterialCode').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#depcode').val('');
$('#AssetDept').val('');
$('#DateOfPurchase').val('');
$('#DeliveryDate').val('');
$('#PODescription').val('');
$('#Assetvalue').val('');
// alert(PONO);
if(PONO){
//alert("INSIDE IF");
$.ajax({
type:'POST',
url:"<?php echo base_url() ?>assetdetails/getpodetails",
data:'PONO='+PONO,
dataType: 'json',
success:function(data){
//alert(data);
var line ='';
var PONO = $(this).val();
$('#SupplierName').val('');
$('#SupID').val('');
$('#MaterialCode').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#depcode').val('');
$('#AssetDept').val('');
$('#DateOfPurchase').val('');
$('#DeliveryDate').val('');
$('#PODescription').val('');
$('#Assetvalue').val('');
// alert(PONO);
if (PONO) {
//alert("INSIDE IF");
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getpodetails",
data: 'PONO=' + PONO,
dataType: 'json',
success: function(data) {
//alert(data);
var line = '';
$('#SelectMaterialCode').empty();
//alert('before');
$.each(data, function (i, item) {
//alert(item);
$.each(data, function(i, item) {
//alert(item);
//line ='<option>select Material Code</option>';
//line ='<option>select Material Code</option>';
//line +='<option value='+item.LineItemNo+'>'+item.LineItemNo+'-'+item.MaterialCode+'</option>';
//$('#DeliveryDate').val(item.DeliveryDate);
line+=item;
$('#SelectMaterialCode').append(line);
//$('#DeliveryDate').val(item.DeliveryDate);
line += item;
$('#SelectMaterialCode').append(line);
});
}
});
}
});
}
});
$('#SelectMaterialCode').on('change',function(){
var line = $(this).val();
});
$('#SelectMaterialCode').on('change', function() {
var line = $(this).val();
//line +='<option>select Material Code</option>'
if(line){
$.ajax({
type:'POST',
url:"<?php echo base_url() ?>assetdetails/getline",
data:'line='+line,
success:function(data){
//alert(data);
var id = $('#SelectMaterialCode').val();
$.each(JSON.parse(data), function (i, item) {
if(id == item.LineItemNo){
$('#DateOfPurchase').val(item.PODate);
if(item.DeliveryDate != null )
{
var date = new Date(item.DeliveryDate);
var date1 = (date.getDate()+ '-' + (date.getMonth() + 1)+ '-' + date.getFullYear());
if(item.DeliveryDate == '0000-00-00' || item.DeliveryDate == '30-11--0001')
{
$('#DeliveryDate').val('');
}
else
{
//alert(item.DeliveryDate+ ',' + date1);
$("#DeliveryDate").val(date1);
}
if (line) {
$.ajax({
type: 'POST',
url: "<?php echo base_url() ?>assetdetails/getline",
data: 'line=' + line,
success: function(data) {
//alert(data);
//var correctDate = [DDate.getDate(),DDate.getMonth()+1,DDate.getFullYear()].join("/");
//alert(correctDate);
var id = $('#SelectMaterialCode').val();
$.each(JSON.parse(data), function(i, item) {
if (id == item.LineItemNo) {
}
else
{
$('#DeliveryDate').val('');
}
$('#SupplierName').val(item.SupplierName);
$('#SupID').val(item.SupplierID);
$('#MaterialCode').val(item.MaterialCode);
$('#UOM').val(item.UOM);
$('#Quantity').val(item.Quantity);
$('#depcode').val(item.Departmentcode);
$('#AssetDept').val(item.DepartmentName);
$('#PODescription').val(item.MaterialName);
$('#Assetvalue').val(item.TotalValue);
//var date = new Date(item.DeliveryDate);
// var date1 = (date.getDate()+ '/' + (date.getMonth() + 1)+ '/' + date.getFullYear());
var date = new Date(item.PODate);
var date3 = (date.getDate()+ '-' + (date.getMonth() + 1)+ '-' + date.getFullYear());
$("#DateOfPurchase").val(date3);
}
//line ='<option>'+item.LineItemNo+'</option>';
// $('#POLineItem').append(line);
});
}
});
$('#DateOfPurchase').val(item.PODate);
if (item.DeliveryDate != null) {
var date = new Date(item.DeliveryDate);
var date1 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
if (item.DeliveryDate == '0000-00-00' || item.DeliveryDate == '30-11--0001') {
$('#DeliveryDate').val('');
} else {
//alert(item.DeliveryDate+ ',' + date1);
$("#DeliveryDate").val(date1);
}
//var correctDate = [DDate.getDate(),DDate.getMonth()+1,DDate.getFullYear()].join("/");
//alert(correctDate);
} else {
$('#DeliveryDate').val('');
}
$('#SupplierName').val(item.SupplierName);
$('#SupID').val(item.SupplierID);
$('#MaterialCode').val(item.MaterialCode);
$('#UOM').val(item.UOM);
$('#Quantity').val(item.Quantity);
$('#depcode').val(item.Departmentcode);
$('#AssetDept').val(item.DepartmentName);
$('#PODescription').val(item.MaterialName);
$('#Assetvalue').val(item.TotalValue);
//var date = new Date(item.DeliveryDate);
// var date1 = (date.getDate()+ '/' + (date.getMonth() + 1)+ '/' + date.getFullYear());
var date = new Date(item.PODate);
var date3 = (date.getDate() + '-' + (date.getMonth() + 1) + '-' + date.getFullYear());
$("#DateOfPurchase").val(date3);
}
//line ='<option>'+item.LineItemNo+'</option>';
// $('#POLineItem').append(line);
});
}
});
}
});
});
</script>

View File

@ -100,233 +100,187 @@ if ($total <= $reorder) {
}
</style>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center> </center>
</h1>
</section>
<section class="content-header">
<h1>
<center> Edit Material - <?php echo $MaterialCode; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>rawmaterialListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section> <br />
<section class="content">
<!-- <div class="row"> -->
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-success">
<!-- form start -->
<form role="form" action="<?php echo base_url() ?>rawmaterialdetails/editRawmaterial" method="post" id="editRawmaterial" role="form">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-2">
<div class="form-group">
<label for="RMcode">MaterialCode</label>
<input type="text" class="form-control" readonly id="RMcode" name="RMcode" maxlength="255" value="<?php echo $MaterialCode; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="MaterialName">Material Name</label>
<font color="Red">*</font>
<input type="text" class="form-control required " id="MaterialName" name="MaterialName" maxlength="255" value="<?php echo htmlentities($MaterialName); ?>">
<input type="hidden" class="form-control required " id="MaterialCode" value="<?php echo $MaterialCode; ?>" name="MaterialCode" maxlength="255">
</div>
</div>
<!-- <div class="col-md-2">
<div class="form-group">
<label for="MaterialType">Material Type</label>
<input type="text" class="form-control" readonly id="MaterialType" name="MaterialType" value="<?php echo $MaterialType; ?>">
</div>
</div> -->
<div class="col-md-2">
<div class="form-group">
<label for="MaterialType">Material Type</label>
<font color="Red">*</font>
<select class="form-control select2" required id="MaterialType" name="MaterialType">
<?php
if (!empty($material)) {
foreach ($material as $SID) {
?>
<option value="<?= $SID->ConfigValue ?>" <?php if (($MaterialType === $SID->ConfigValue)) echo "selected"; ?>>
<?php echo $SID->ConfigValue ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group autoSearch" id="mc">
<label for="Matcate">Material Caterogy</label>
<font color="Red">*</font>
<input type="text" class="form-control required " required id="MaterialCategory" name="MaterialCategory" value="<?php echo $MaterialCategory; ?>" maxlength="255">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="UOM">Unit of Measurement</label>
<font color="Red">*</font>
<!-- <select class="form-control select2 required " required id="UOM" name="UOM">
<option value=" ">Select UOM</option>
</select> -->
<select class="form-control required select2" id="UOM" name="UOM"> <!-- onchange="changeTextBox();" -->
<option value="<?php echo $UOM; ?>"><?php echo $UOM; ?></option>
<?php
if (!empty($UOMList)) {
foreach ($UOMList as $UM) {
?>
<option value="<?php echo $UM->ConfigValue; ?>"><?php echo $UM->ConfigValue ?>
<?php
}
}
?>
</select>
</div>
</div>
</div>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- Start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Material - <?php echo $MaterialCode; ?> Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>rawmaterialListing">
<span class="bold">Back</span>
</a>
</div>
</div>
<!-- End page title -->
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<label for="HSNcode">HSN code</label>
<input type="text" class="form-control" id="HSNcode" name="HSNcode" maxlength="8" value="<?php echo $HSNcode; ?>" onkeypress="return isNumberKey(event)">
</div>
</div>
<?php
if ($openstock != "") {
?>
<div class="col-md-3">
<div class="form-group autoSearch" id="mc">
<label for="Matcate">Opening Stock</label>
<input type="text" class="form-control required " id="openstock" name="openstock" value="<?php echo $openstock; ?>" maxlength="255">
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" action="<?php echo base_url() ?>rawmaterialdetails/editRawmaterial" method="post" id="editRawmaterial">
<div class="box-body">
<!-- Material Information -->
<div class="row">
<div class="col-md-12">
<div class="form-row mb-3">
<div class="col-md-3">
<div class="form-group">
<label for="RMcode">Material Code</label>
<input type="text" class="form-control" readonly id="RMcode" name="RMcode" maxlength="255" value="<?php echo $MaterialCode; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="MaterialName">Material Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="MaterialName" name="MaterialName" maxlength="255" value="<?php echo htmlentities($MaterialName); ?>" required>
<input type="hidden" class="form-control" id="MaterialCode" name="MaterialCode" maxlength="255" value="<?php echo $MaterialCode; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="MaterialType">Material Type <span class="text-danger">*</span></label>
<select class="form-control select2" id="MaterialType" name="MaterialType" required>
<?php
if (!empty($material)) {
foreach ($material as $SID) {
?>
<option value="<?= $SID->ConfigValue ?>" <?php if ($MaterialType === $SID->ConfigValue) echo "selected"; ?>>
<?php echo $SID->ConfigValue ?>
</option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="MaterialCategory">Material Category <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="MaterialCategory" name="MaterialCategory" value="<?php echo $MaterialCategory; ?>" maxlength="255" required>
</div>
</div>
</div>
<div class="form-row mb-3">
<div class="col-md-3">
<div class="form-group">
<label for="UOM">Unit of Measurement <span class="text-danger">*</span></label>
<select class="form-control select2" id="UOM" name="UOM" required>
<option value="<?php echo $UOM; ?>"><?php echo $UOM; ?></option>
<?php
if (!empty($UOMList)) {
foreach ($UOMList as $UM) {
?>
<option value="<?php echo $UM->ConfigValue; ?>"><?php echo $UM->ConfigValue ?></option>
<?php
}
}
?>
</select>
</div>
</div>
</div>
<?php
<div class="col-md-3">
<div class="form-group">
<label for="HSNcode">HSN Code</label>
<input type="text" class="form-control" id="HSNcode" name="HSNcode" maxlength="8" value="<?php echo $HSNcode; ?>" onkeypress="return isNumberKey(event)">
</div>
</div>
<?php if ($openstock != "") { ?>
<div class="col-md-3">
<div class="form-group">
<label for="openstock">Opening Stock</label>
<input type="text" class="form-control" id="openstock" name="openstock" value="<?php echo $openstock; ?>" maxlength="255">
</div>
</div>
<?php } else { ?>
<div class="col-md-3">
<div class="form-group">
<label for="openstock">Opening Stock</label>
<input type="text" class="form-control" id="openstock" name="openstock" maxlength="255">
</div>
</div>
<?php } ?>
} else {
?>
<div class="col-md-3">
<div class="form-group">
<label for="conversionfactor">Opening Stock</label>
<input type="text" class="form-control" id="openstock" name="openstock" maxlength="255">
<?php if ($date != "") { ?>
<div class="col-md-3">
<div class="form-group">
<label>Open Stock Date</label>
<input type="text" name="Date" id="Date" class="form-control" value="<?php echo $date; ?>" readonly>
</div>
</div>
<?php } else { ?>
<div class="col-md-3">
<div class="form-group">
<label>Open Stock Date</label>
<input type="text" name="Date" id="Date" class="form-control" readonly>
</div>
</div>
<?php } ?>
</div>
<div class="form-row mb-3">
<div class="col-md-3">
<div class="form-group">
<label for="reorder">Reorder Level</label>
<input type="text" class="form-control" id="reorder" name="reorder" value="<?php echo $reorder; ?>" maxlength="255">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="currentstock">Current Stock</label>
<input type="text" class="form-control" id="currentstock" name="currentstock" readonly value="<?php echo $total; ?>" maxlength="255">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="avg_price">Average Price</label>
<input type="text" class="form-control" id="avg_price" name="avg_price" readonly value="<?php echo $Average_Value ?>" maxlength="255">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="remarks">Remarks</label>
<input type="text" class="form-control" id="remarks" name="remarks" maxlength="255" value="<?php echo $remarks; ?>">
</div>
</div>
</div>
<div class="form-row mb-3">
<div class="col-md-2">
<div class="form-group">
<label for="isactive">Is Active</label><br />
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive; ?>>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
<?php
if ($date != "") {
?>
<div class="col-md-3">
<label>Open Stock Date</label>
<?php
// $data = array('name' => 'Date','value' => set_value('Date',$date), 'class' => 'form-control','readonly'=>'true', 'onkeypress'=>'return false;');
$data = array('name' => 'Date', 'id' => 'Date', 'value' => set_value('Date', $date), 'class' => 'form-control', 'onkeypress' => 'return false;');
echo form_input($data);
?>
</div>
<?php
} else {
?>
<div class="col-md-3">
<label>Open Stock Date</label>
<?php
$data = array('name' => 'Date', 'id' => 'Date', 'class' => 'form-control', 'onkeypress' => 'return false;');
echo form_input($data);
?>
</div>
<?php
}
?>
<div class="col-md-3">
<div class="form-group">
<label for="conversionfactor">Reorder Level</label>
<input type="text" class="form-control" id="reorder" value="<?php echo $reorder; ?>" name="reorder" maxlength="255">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<label for="conversionfactor">Current Stock</label>
<input type="text" class="form-control" id="currentstock" readonly value="<?php echo $total; ?>" name="currentstock" maxlength="255">
</div>
<div class="box-footer text-right">
<a href="<?php echo base_url() ?>rawmaterialListing" class="btn btn-cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</form>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /.content -->
</div><!-- /.content-page -->
<div class="col-md-3">
<div class="form-group">
<label for="conversionfactor">Average Price</label>
<input type="text" class="form-control" id="avg_price" readonly value="<?php echo $Average_Value ?>" name="avg_price" maxlength="255">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="remarks">Remarks</label>
<input type="text" class="form-control" id="remarks" name="remarks" maxlength="255" value="<?php echo $remarks; ?>">
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="Active">IsActive</label> <br />
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive; ?>>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer" style="text-align:right">
<a href="<?php echo base_url() ?>rawmaterialListing" class="btn btn-cancel" value="Cancel" />Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</form>
</div><!-- /.box-body -->
</div>
</div>
</div>
</section>
</div>
<script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script>
<script>

View File

@ -233,7 +233,7 @@ if (!empty($supplier)) {
<style>
legend {
border-bottom: 2px solid #FFF !important;
margin-left: -2%;
margin-left: 0%;
}
.text-right {
@ -245,219 +245,224 @@ if (!empty($supplier)) {
background-color: #fff;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center> Edit <?php echo $SupplierName; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section>
<br/>
<section class="content" id="content">
<div class="row">
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-success">
<div class="row" style="font-size:11px; padding-left:38px;">
<div class="col-md-12">
<form class="form-horizontal" role="form" id="UpdateSupplier" action="<?php echo base_url() ?>editsupplier" method="post" role="form" enctype="multipart/form-data">
<div class="box-body">
<?php if((int)$chk){ ?>
<div class="col-md-12 text-right">
<input type="checkbox" id="isactive" <?php echo $IsActive; ?> name="isactive"> IsActive
</div>
<?php } ?>
<!-- Form Name -->
<legend>Supplier Information</legend>
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-2">
<span for="SupplierID">Supplier ID</span>
<input type="text" name="SupplierID" id="SupplierID" class="form-control" readonly value="<?php echo $SupplierID; ?>">
</div>
<div class="col-md-3">
<span for="SupplierName">Supplier Name</span><span class="badge">*</span>
<input type="text" name="SupplierName" maxlength="100" id="supplierName" class="form-control" required value="<?php echo $SupplierName; ?>">
</div>
<div class="col-md-2">
<span for="ContactNumber">Contact Number</span><span class="badge">*</span>
<input type="text" name="ContactNumber" onchange="return getContactNumberValidation();" id="ContactNumber" required maxlength="13" class="form-control" value="<?php echo $ContactNumber; ?>" title="Please Enter Contact Number (or) Telephone Number" onkeypress="return isNumberKey(event)">
</div>
<div class="col-md-2">
<span for="AlternateContactNumber">Alternate Contact Number</span>
<input type="text" name="AlternateContactNumber" onchange="return getValidAlternateNumber();" id="AlternateContactNumber" maxlength="13" class="form-control" value="<?php echo $AlternateContactNumber; ?>" title="Please Enter Contact Number (or) Telephone Number" onkeypress="return isNumberKey(event)">
</div>
<div class="col-md-3">
<span for="EmailAddress">Email ID</span><span class="badge">*</span>
<input type="email" name="emailid" id="emailid" pattern="([A-Z0-9_\-\.])+\@([A-Z0-9_\-\.])+\.([A-Z]{2,4})" required maxlength="100" class="form-control" value="<?php echo $EmailAddress; ?>" title="Please Enter valid mail address" onchange="validateEmail();">
</div>
</div>
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-6"><span for="SupplierType">Supplier Type :</span><!--<span class="badge">*</span>-->
&ensp;
<input type="checkbox" id="service" <?php echo $IsService; ?> name="service" value="1"> <b>SERVICE &ensp;</b>
<input type="checkbox" id="rawmaterial" <?php echo $IsRawMaterial; ?> name="rawmaterial" value="1"> <b>RAW MATERIALS &ensp;</b>
<input type="checkbox" id="maintanance" <?php echo $IsMaintanance; ?> name="maintanance" value="1"> <b>MAINTENANCE &ensp;</b>
</div>
</div>
<!-- Address Section -->
<!-- Form Name -->
<legend>Address Details</legend>
<!-- Text input-->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-12">
<span for="Address2">Address</span><span class="badge">*</span>
<input type="text" class="form-control required" id="Address" name="Address" maxlength="500" required value="<?php echo $Address; ?>">
</div>
</div>
<legend>Tax Related Data</legend>
<!-- Text input-->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-3"><span for="GSTNo">GST Number</span><!--<span class="badge">*</span>-->
<input type="text" id="GSTNo" name="GSTNo" onchange="validateGST();" maxlength="15" class="form-control" value="<?php echo $GSTNO; ?>" pattern="([0-9]){2}([A-Za-z]){5}([0-9]){4}([A-Za-z]){1}([0-9]){1}([Zz]){1}([A-Za-z0-9]){1}" style="text-transform:uppercase;" title="Please Enter 2 Digit Number and 5 Character and 4 Digit Numbers and 1 Character and 1 Number and 'Z' Character and 1 Number (or) Character " onkeypress="return alphaNumberic(event)">
</div>
<div class="col-md-3"><span for="PAN">PAN</span> <!--<span class="badge">*</span>-->
<input type="text" id="panno" maxlength="10" name="panno" onchange="validatePAN();" class="form-control" value="<?php echo $PAN; ?>" title="Please Enter 5 Character and 4 digit numbers and 1 Character format (Character must be in caps format)" pattern="([A-Za-z]){5}([0-9]){4}([A-Za-z]){1}" onkeypress="return alphaNumberic(event)" style="text-transform:uppercase;">
</div>
<div class="col-md-3">
<input type="file" size="20" accept=".docx,.pdf,.doc,.jpg,.png" id="Cert_GST" name="Cert_GST"/>
<label for="Cert_GST">Select GST Document<br/><small>(only .pdf, .doc, .png, .jpg)</small></label>
<input type="hidden" id="hidden_Cert_GST" name="hidden_Cert_GST" value="<?php echo $hidden_Cert_GST; ?>"/>
</div>
<?php if($hidden_Cert_GST){ ?>
<div class="col-md-3">
<u><a title="previously uploaded GST Document" href="<?php echo base_url().'public/uploads/images/' . $hidden_Cert_GST ?>"><span>previously uploaded GST Document - </span><small><?= $hidden_Cert_GST; ?></small></a></u>
</div>
<?php } ?>
</div>
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-6"><span for="MSMENo">MSME Number</span>
<input type="text" id="MSMENo" name="MSME" class="form-control" value="<?php echo $MSME; ?>" maxlength="30">
</div>
<div class="col-md-3">
<input type="file" size="20" accept=".docx,.pdf,.doc,.jpg,.png" id="Cert_MSME" name="Cert_MSME"/>
<label for="Cert_MSME">Select MSME Document<br/><small>(only .pdf, .doc, .png, .jpg)</small></label>
<input type="hidden" id="hidden_Cert_MSME" name="hidden_Cert_MSME" value="<?php echo $hidden_Cert_MSME; ?>"/>
</div>
<?php if($hidden_Cert_MSME){ ?>
<div class="col-md-3">
<u> <a title="previously uploaded MSME Document" href="<?php echo base_url().'public/uploads/images/' . $hidden_Cert_MSME ?>"><span>previously uploaded MSME Document - </span><small><?= $hidden_Cert_MSME; ?></small></a></u>
</div>
<?php } ?>
</div>
<legend>Bank Details</legend>
<!-- Text input-->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-3"><span>Account Number</span><span class="badge">*</span>
<input type="text" id="accno" maxlength="20" name="accno" value="<?php echo $accno; ?>" class="form-control" onkeypress="return isNumberKey(event)" required>
</div>
<div class="col-md-3"><span>IFSC Code</span><span class="badge">*</span>
<input type="text" id="ifsc" name="ifsc" value="<?php echo $IFSCCode; ?>" class="form-control" maxlength="12" style="text-transform: uppercase" required>
</div>
<div class="col-md-3"><span>Bank Branch Name</span>
<input type="text" id="branchname" name="branchname" value="<?php echo $branchname; ?>" class="form-control" maxlength="200">
</div>
<div class="col-md-3"><span>Bank Address</span>
<input type="text" id="bankaddress" name="bankaddress" value="<?php echo $bankaddress; ?>" class="form-control" maxlength="200">
</div>
</div>
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-3">
<input type="file" size="20" accept=".docx,.pdf,.doc,.jpg,.png" id="Cert_BANK" name="Cert_BANK"/>
<label for="Cert_BANK">Select Bank Document<br/><small>(only .pdf, .doc, .png, .jpg)</small></label>
<input type="hidden" id="hidden_Cert_BANK" name="hidden_Cert_BANK" value="<?php echo $hidden_Cert_BANK; ?>"/>
</div>
<?php if($hidden_Cert_BANK){ ?>
<div class="col-md-3">
<u><a title="previously uploaded Bank Document" href="<?php echo base_url().'public/uploads/images/' . $hidden_Cert_BANK ?>"><span>previously uploaded BANK Document - </span><small><?= $hidden_Cert_BANK; ?></small></a></u>
</div>
<?php } ?>
</div>
<!-- Text input-->
<legend>Payment Details</legend>
<!-- Text input-->
<div class="col-md-12" style="margin-bottom: 27px;">
<div class="col-md-3">
<span for="payablefrom">Payable Terms</span>
<select class="form-control required select2" id="PaymentTerms" name="PaymentTerms" onchange="payment_hidden();"><!-- placeholder="Select ">-->
<option value="<?php echo $PaymentTerms; ?>"><?php echo $PaymentTerms; ?></option>
<?php
if (!empty($payment)) {
foreach ($payment as $pm) {
?>
<option value="<?php echo $pm->PaymentID ?>"><?php echo $pm->PaymentTerms ?></option>
<?php
}
}
?>
</select>
<input type="hidden" id="paymentid" name="paymentid" value="<?php echo $PaymentId; ?>">
<!--<input type="hidden" id="paymentname" name="paymentname" value="<?php echo $PaymentId; ?>"> -->
</div>
</div>
<div class="col-md-12 text-right">
<a href="<?php echo base_url() ?>supplierlisting" class="btn btn-cancel" value="Cancel" />Cancel</a>
<?php if((int)$chk){ ?>
<input type="submit" onclick="validate();" value="Submit" class="btn btn-success">
<?php } ?>
</div>
</div>
</form>
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
</div>
</div>
<div class="col-md-4">
<div class="content-page">
<div class="content">
<?php helper('form'); ?>
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('error'); ?>
</div>
if ($error) { ?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><EFBFBD></button>
<?php echo session()->getFlashdata('success'); ?>
</div>
if ($success) { ?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- Start Content-->
<div class="container-fluid">
<div class="box box-success">
<?php if (!empty($validation)) : ?>
<div class="alert alert-danger">
<ul>
<?php foreach ($validation as $error) : ?>
<li><?= esc($error) ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<!-- form start -->
</div>
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Supplier Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>supplierlisting"><span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="p-2">
<form class="form-horizontal" role="form" id="UpdateSupplier" action="<?php echo base_url() ?>editsupplier" method="post" enctype="multipart/form-data">
<div class="box-body">
<?php if ((int)$chk) { ?>
<div class="col-md-12 text-right">
<input type="checkbox" id="isactive" <?php echo $IsActive; ?> name="isactive"> IsActive
</div>
<?php } ?>
<!-- Supplier Information -->
<legend>Supplier Information</legend>
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="SupplierName">Supplier Name<span class="badge">*</span></label>
<input type="text" name="SupplierName" maxlength="100" id="supplierName" class="form-control" required value="<?php echo $SupplierName; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="ContactNumber">Contact Number<span class="badge">*</span></label>
<input type="text" name="ContactNumber" onchange="return getContactNumberValidation();" id="ContactNumber" required maxlength="13" class="form-control" value="<?php echo $ContactNumber; ?>" title="Please Enter Mobile Number (or) Telephone Number" onkeypress="return isNumberKey(event)">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AlternateContactNumber">Alternate Contact Number</label>
<input type="text" name="AlternateContactNumber" onchange="return getValidAlternateNumber();" id="AlternateContactNumber" maxlength="13" class="form-control" value="<?php echo $AlternateContactNumber; ?>" title="Please Enter Mobile Number (or) Telephone Number" onkeypress="return isNumberKey(event)">
</div>
<div class="col-md-3">
<label class="col-form-label" for="EmailAddress">Email ID<span class="badge">*</span></label>
<input type="email" name="emailid" id="emailid" required maxlength="100" class="form-control" value="<?php echo $EmailAddress; ?>" title="Please Enter valid mail address" onchange="validateEmail();">
</div>
</div>
<div class="form-row" style="margin-top:20px;">
<div class="col-md-12">
<label for="SupplierType">Supplier Type</label>
</div>
<div class="col-md-3">
<input type="checkbox" id="service" <?php echo $IsService; ?> name="service" value="1"> <b>SERVICE</b>
</div>
<div class="col-md-3">
<input type="checkbox" id="rawmaterial" <?php echo $IsRawMaterial; ?> name="rawmaterial" value="1"> <b>RAW MATERIALS</b>
</div>
<div class="col-md-3">
<input type="checkbox" id="maintanance" <?php echo $IsMaintanance; ?> name="maintanance" value="1"> <b>MAINTENANCE</b>
</div>
</div>
<!-- Address Section -->
<legend style="margin-top:30px;">Address Details</legend>
<div class="form-row">
<div class="col-md-12">
<label for="Address2">Address<span class="badge">*</span></label>
<input type="text" class="form-control" id="Address" name="Address" maxlength="500" required value="<?php echo $Address; ?>">
</div>
</div>
<!-- Tax Related Data -->
<legend style="margin-top:30px;">Tax Related Data</legend>
<div class="form-row">
<div class="col-md-3">
<label for="GSTNo">GST Number</label>
<input type="text" id="GSTNo" name="GSTNo" onchange="validateGST();" maxlength="15" class="form-control" value="<?php echo $GSTNO; ?>" pattern="([0-9]){2}([A-Za-z]){5}([0-9]){4}([A-Za-z]){1}([0-9]){1}([Zz]){1}([A-Za-z0-9]){1}" style="text-transform:uppercase;" title="Please Enter 2 Digit Number and 5 Character and 4 Digit Numbers and 1 Character and 1 Number and 'Z' Character and 1 Number (or) Character " onkeypress="return alphaNumberic(event)">
</div>
<div class="col-md-3">
<label for="PAN">PAN</label>
<input type="text" id="panno" maxlength="10" name="panno" onchange="validatePAN();" class="form-control" value="<?php echo $PAN; ?>" title="Please Enter 5 Character and 4 digit numbers and 1 Character format (Character must be in caps format)" pattern="([A-Za-z]){5}([0-9]){4}([A-Za-z]){1}" onkeypress="return alphaNumberic(event)" style="text-transform:uppercase;">
</div>
<div class="col-md-3">
<input type="file" size="20" accept=".docx,.pdf,.doc,.jpg,.png" id="Cert_GST" name="Cert_GST" />
<label for="Cert_GST">Select GST Document<br /><small>(only .pdf, .doc, .png, .jpg)</small></label>
<input type="hidden" id="hidden_Cert_GST" name="hidden_Cert_GST" value="<?php echo $hidden_Cert_GST; ?>" />
</div>
<?php if ($hidden_Cert_GST) { ?>
<div class="col-md-3">
<u><a title="previously uploaded GST Document" href="<?php echo base_url() . 'public/uploads/images/' . $hidden_Cert_GST ?>"><span>previously uploaded GST Document - </span><small><?= $hidden_Cert_GST; ?></small></a></u>
</div>
<?php } ?>
</div>
<legend>Bank Details</legend>
<!-- Bank Details Inputs -->
<div class="form-row" style="margin-bottom: 27px;">
<div class="col-md-3">
<label for="accno">Account Number <span class="badge">*</span></label>
<input type="text" id="accno" maxlength="20" name="accno" value="<?php echo $accno; ?>" class="form-control" onkeypress="return isNumberKey(event)" required>
</div>
<div class="col-md-3">
<label for="ifsc">IFSC Code <span class="badge">*</span></label>
<input type="text" id="ifsc" name="ifsc" value="<?php echo $IFSCCode; ?>" class="form-control" maxlength="12" style="text-transform: uppercase" required>
</div>
<div class="col-md-3">
<label for="branchname">Bank Branch Name</label>
<input type="text" id="branchname" name="branchname" value="<?php echo $branchname; ?>" class="form-control" maxlength="200">
</div>
<div class="col-md-3">
<label for="bankaddress">Bank Address</label>
<input type="text" id="bankaddress" name="bankaddress" value="<?php echo $bankaddress; ?>" class="form-control" maxlength="200">
</div>
</div>
<!-- Bank Document Upload -->
<div class="form-row" style="margin-bottom: 27px;">
<div class="col-md-3">
<input type="file" size="20" accept=".docx,.pdf,.doc,.jpg,.png" id="Cert_BANK" name="Cert_BANK" />
<label for="Cert_BANK">Select Bank Document<br /><small>(only .pdf, .doc, .png, .jpg)</small></label>
<input type="hidden" id="hidden_Cert_BANK" name="hidden_Cert_BANK" value="<?php echo $hidden_Cert_BANK; ?>" />
</div>
<?php if ($hidden_Cert_BANK) { ?>
<div class="col-md-3">
<u>
<a title="Previously uploaded Bank Document" href="<?php echo base_url() . 'public/uploads/images/' . $hidden_Cert_BANK ?>">
<span>Previously uploaded BANK Document - </span>
<small><?php echo $hidden_Cert_BANK; ?></small>
</a>
</u>
</div>
<?php } ?>
</div>
<!-- Payment Details -->
<legend>Payment Details</legend>
<!-- Payable Terms Selection -->
<div class="form-row" style="margin-bottom: 27px;">
<div class="col-md-3">
<label for="payablefrom">Payable Terms</label>
<select class="form-control required select2" id="PaymentTerms" name="PaymentTerms" onchange="payment_hidden();">
<option value="<?php echo $PaymentTerms; ?>"><?php echo $PaymentTerms; ?></option>
<?php
if (!empty($payment)) {
foreach ($payment as $pm) { ?>
<option value="<?php echo $pm->PaymentID; ?>"><?php echo $pm->PaymentTerms; ?></option>
<?php
}
}
?>
</select>
<input type="hidden" id="paymentid" name="paymentid" value="<?php echo $PaymentId; ?>">
<!-- Uncomment the next line if you need the payment name in hidden input -->
<!-- <input type="hidden" id="paymentname" name="paymentname" value="<?php echo $PaymentId; ?>"> -->
</div>
</div>
<br />
<div class="col-md-12">
<div class="form-group row text-right">
<div class="col-12">
<button type="submit" class="btn btn-info pull-right">Submit</button>
</div>
</div>
</div>
<!-- /.box-footer -->
</div>
</form>
</div> <!-- end p-2 -->
</div> <!-- end col -->
</div> <!-- end row -->
</div> <!-- end card-body -->
</div> <!-- end card -->
</div> <!-- end col -->
</div> <!-- end row -->
</div> <!-- end container-fluid -->
</div> <!-- end content -->
</div> <!-- end content-page -->
<div class="row">
<div class="col-md-12">
<?php // echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><3E></button></div>'); ?>
</div>
</div>
</div>
</div>
</section>
</div>
<script>
function payment_hidden() {
var term = document.getElementById("PaymentTerms");
@ -510,33 +515,34 @@ if (!empty($supplier)) {
var supplier = suppliername.replace(/ /g, '');
$('#content').loader('show');
$.ajax({
type: "POST",
url: "<?= base_url() . 'supplierExist' ?>",
data: { id: supplier },
success: function(data) {
var count = data.length;
if (count > 2) {
$('#content').loader('hide');
alert('supplier already existed ! ');
var related_supplier = "";
$.each(data, function(i, obj) {
related_supplier += obj.SupplierID + " - " + obj.SupplierName + " - " + obj.Address + "\n";
});
alert("'" + suppliername + "' - related supplier are , " + " \n \n" + related_supplier);
$("#supplierName").focus();
} else {
$('#content').loader('hide');
// alert('This is New Supplier! ');
}
console.log(data);
},
error: function() {
$('#content').loader('hide');
// alert("Error Occur");
console.log("an error occur supplierExist")
}
});
});
type: "POST",
url: "<?= base_url() . 'supplierExist' ?>",
data: {
id: supplier
},
success: function(data) {
var count = data.length;
if (count > 2) {
$('#content').loader('hide');
alert('supplier already existed ! ');
var related_supplier = "";
$.each(data, function(i, obj) {
related_supplier += obj.SupplierID + " - " + obj.SupplierName + " - " + obj.Address + "\n";
});
alert("'" + suppliername + "' - related supplier are , " + " \n \n" + related_supplier);
$("#supplierName").focus();
} else {
$('#content').loader('hide');
// alert('This is New Supplier! ');
}
console.log(data);
},
error: function() {
$('#content').loader('hide');
// alert("Error Occur");
console.log("an error occur supplierExist")
}
});
});
</script>

View File

@ -101,293 +101,185 @@ if(!empty($assetList))
?>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center><?= 'Edit Asset - ' .$AssetCode; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section><br>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url()?>assetListing" class="btn btn-cancel"value="Back">Back</a>
</div>
<br>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box box-success">
<!-- form start -->
<form role="form" id="addAsset" action="<?php echo base_url() ?>editasset" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Asset_Name">Asset Name</span><span style="color:red">*</span>
</b>
<input type="text" class="form-control required" id="AssetName" name="AssetName" value="<?php echo $AssetName;?>" style="text-transform:uppercase;">
<input type="hidden" name="AssetCode" id="AssetCode" class="form-control" readonly value="<?php echo $AssetCode;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Description">Asset Description</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="Description" name="Description"
value="<?php echo $Description; ?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="AssetOwner">Asset User</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="User" name="User" value="<?php echo $User;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Location">Asset Location</span><span style="color:red">*</span></b>
<input type="text" class="form-control required" id="Location" name="Location"
value="<?php echo $Location;?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<b>
<span for="PONO">Purchase Order Number</span><span style="color:red">*</span></b>
<select class="form-control required select2" id="PONO" name="PONO">
<option value="<?php echo $PONO;?>"><?php echo $PONO;?></option>
<?php
if(!empty($PO))
{
foreach ($PO as $po)
{
$PONO1 = $po->PONO;
if(trim($PONO1) != trim($PONO))
{
if ($_POST['PONO'] == $PONO1)
{
echo "<option value=\"".$PONO1."\" selected=\"selected\">". $po->PONO."</option>";
}
else
{
echo "<option value=\"".$PONO1."\">". $po->PONO ."</option>";
}
}
}
}
?>
</select>
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group">
<b>
<span for="SelectMaterialCode" value=""> select Material Code</span>
</b>
<select class="form-control required select2" id="SelectMaterialCode" name="lineitem">
<option value="<?php echo $POLineItem;?>"><?php echo $POLineItem;?></option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<b>
<span for="MaterialCode">Material Code</span></b>
<input type="text" class="form-control required" id="MaterialCode" readonly name="MaterialCode" value="<?php echo $MaterialCode;?>">
</div>
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group">
<b>
<span for="UOM">UOM</span></b>
<input type="text" class="form-control required" id="UOM"value="<?php echo $UOM;?>"readonly name="UOM" value="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<b>
<span for="Quantity">Quantity</span></b>
<input type="text" class="form-control required" id="Quantity" value="<?php echo $Quantity;?>" name="Quantity" value="">
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="Description">Description</span></b>
<input type="text" class="form-control required" id="PODescription" readonly name="PODescription" value="<?php echo $MaterialName;?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<input type="hidden" name="AssetDept" id="depcode" value="<?php echo $Department?>">
<b>
<span for="AssetDept">Asset Department</span></b>
<input type="text" class="form-control required" value="<?php echo $DepartmentName;?>" id="AssetDept" readonly>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="DateOfPurchase">Purchase Date</span></b>
<input id="DateOfPurchase" required name="DateOfPurchase" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $DateOfPurchase;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<b>
<span for="DateOfPurchase">Supplier Name</span></b>
<input type="hidden" name="SupplierName" id="SupID" value="<?php echo $SupplierCode;?>">
<input id="SupplierName" readonly onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $SupplierName; ?>">
</div>
</div>
<div class="col-md-3" style="padding:0px;">
<div class="col-md-6">
<div class="form-group"><b>
<span for="DeliveryDate">Delivery Date</span></b>
<input id="DeliveryDate" readonly name="DeliveryDate" maxlength="10" class="form-control" value= "<?php echo $DeliveryDate;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group"><b>
<span for="DateOfCommission">Date Of Commission</span></b>
<input id="DateOfCommission" required name="DateOfCommission" onkeypress="return false;" maxlength="10" class="form-control" value= "<?php echo $DateOfCommison;?>">
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group"><b>
<span for="Assetvalue">Asset Value</span>
</b> <input type="text" class="form-control required" id="Assetvalue" name="Assetvalue" onkeypress="return isNumberKey(event)" maxlength="255" value="<?php echo $AssetValue;?>">
</div>
</div>
<div class="col-md-3">
<div class="form-group"><b>
<span for="AssetStatus">Asset Status</span></b>
<select class="form-control required" id="AssetStatus" name="AssetStatus">
<option value="<?php echo $AssetStatus; ?>"><?php echo $AssetStatus; ?></option>
<?php
if(!empty($AssetStatusList))
{
foreach ($AssetStatusList as $SID)
{
?>
<option value="<?php echo $SID->ConfigValue; ?>"> <?php echo $SID->ConfigValue ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group"><b>
<span for="Remarks">Remarks</span>
</b>
<input type="text" class="form-control required" id="Remarks" name="Remarks" maxlength="500" value="<?php echo $Remarks; ?>">
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-3">
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive ?> > IsActive
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<a href="<?php echo base_url()?>assetListing" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title text-center"><?= 'Edit Asset - ' . $AssetCode; ?> Details</h4>
</div>
</div>
</form>
</div>
<div class="col-md-4">
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?> </div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>assetListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="addAsset" action="<?php echo base_url() ?>editasset" method="post">
<div class="box-body">
<div class="form-row">
<div class="col-md-3">
<label class="col-form-label" for="AssetName">Asset Name<span class="badge">*</span></label>
<input type="text" class="form-control" id="AssetName" name="AssetName" value="<?php echo $AssetName;?>" style="text-transform:uppercase;">
<input type="hidden" name="AssetCode" id="AssetCode" class="form-control" readonly value="<?php echo $AssetCode;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Description">Asset Description<span class="badge">*</span></label>
<input type="text" class="form-control" id="Description" name="Description" value="<?php echo $Description; ?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="User">Asset User<span class="badge">*</span></label>
<input type="text" class="form-control" id="User" name="User" value="<?php echo $User;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Location">Asset Location<span class="badge">*</span></label>
<input type="text" class="form-control" id="Location" name="Location" value="<?php echo $Location;?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="PONO">Purchase Order Number<span class="badge">*</span></label>
<select class="form-control select2" id="PONO" name="PONO">
<option value="<?php echo $PONO;?>"><?php echo $PONO;?></option>
<?php if(!empty($purchaseOrder))
{
foreach($purchaseOrder as $order)
{ ?>
<option value="<?php echo $order->purchase_orderno; ?>"><?php echo $order->purchase_orderno; ?></option>
<?php }
}?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Category">Asset Category<span class="badge">*</span></label>
<select class="form-control select2" id="Category" name="Category">
<option value="<?php echo $Category;?>"><?php echo $CategoryName;?></option>
<?php if(!empty($categories))
{
foreach($categories as $cat)
{ ?>
<option value="<?php echo $cat->id; ?>"><?php echo $cat->name; ?></option>
<?php }
}?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetType">Asset Type<span class="badge">*</span></label>
<select class="form-control select2" id="AssetType" name="AssetType">
<option value="<?php echo $AssetType;?>"><?php echo $AssetType;?></option>
<option value="Fixed">Fixed</option>
<option value="Consumable">Consumable</option>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetSubType">Asset Sub-Type<span class="badge">*</span></label>
<select class="form-control select2" id="AssetSubType" name="AssetSubType">
<option value="<?php echo $AssetSubType;?>"><?php echo $AssetSubType;?></option>
<option value="Individual">Individual</option>
<option value="Common">Common</option>
</select>
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="PDate">Purchase Date<span class="badge">*</span></label>
<input type="text" class="form-control" id="PDate" name="PDate" value="<?php echo $PDate;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Vendor">Vendor<span class="badge">*</span></label>
<select class="form-control select2" id="Vendor" name="Vendor">
<option value="<?php echo $Vendor;?>"><?php echo $VendorName;?></option>
<?php if(!empty($vendors))
{
foreach($vendors as $vendor)
{ ?>
<option value="<?php echo $vendor->id; ?>"><?php echo $vendor->name; ?></option>
<?php }
}?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Rate">Rate<span class="badge">*</span></label>
<input type="text" class="form-control" id="Rate" name="Rate" value="<?php echo $Rate;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Life">Life<span class="badge">*</span></label>
<input type="text" class="form-control" id="Life" name="Life" value="<?php echo $Life;?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="AssetDept">Asset Department</label>
<input type="text" class="form-control" value="<?php echo $DepartmentName;?>" id="AssetDept" readonly>
<input type="hidden" name="AssetDept" id="depcode" value="<?php echo $Department?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AssetOwner">Asset Owner</label>
<select class="form-control select2" id="AssetOwner" name="AssetOwner">
<option value="<?php echo $AssetOwner;?>"><?php echo $AssetOwnerName;?></option>
<?php if(!empty($owners))
{
foreach($owners as $owner)
{ ?>
<option value="<?php echo $owner->id; ?>"><?php echo $owner->name; ?></option>
<?php }
}?>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="VendorWarranty">Vendor Warranty</label>
<input type="text" class="form-control" id="VendorWarranty" name="VendorWarranty" value="<?php echo $VendorWarranty;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="AMC">AMC Details</label>
<input type="text" class="form-control" id="AMC" name="AMC" value="<?php echo $AMC;?>">
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-3">
<label class="col-form-label" for="AssetLocation">Current Asset Location</label>
<input type="text" class="form-control" id="AssetLocation" name="AssetLocation" value="<?php echo $AssetLocation;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Custodian">Custodian Name</label>
<input type="text" class="form-control" id="Custodian" name="Custodian" value="<?php echo $Custodian;?>">
</div>
<div class="col-md-3">
<label class="col-form-label" for="Condition">Condition</label>
<select class="form-control select2" id="Condition" name="Condition">
<option value="<?php echo $Condition;?>"><?php echo $Condition;?></option>
<option value="Good">Good</option>
<option value="Average">Average</option>
<option value="Poor">Poor</option>
</select>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Remarks">Remarks</label>
<textarea class="form-control" id="Remarks" name="Remarks"><?php echo $Remarks;?></textarea>
</div>
</div>
<div class="form-row" style="margin-top:20px">
<div class="col-md-12 text-right">
<a href="<?php echo base_url()?>assetListing" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</div>
</div><!-- /.box-body -->
</form>
</div><!-- /.card-body -->
</div><!-- /.card -->
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div><!-- /.content -->
</div><!-- /.content-page -->
<script src="<?php echo base_url(); ?>public/assets/js/addUser.js" type="text/javascript"></script>
<script>

View File

@ -19,267 +19,244 @@ if (!empty($master)) {
}
?>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Edit Config <?= ' - '.$ConfigName; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>configlisting">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section><br>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Config <?= ' - ' . $ConfigName; ?> Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>configlisting"><span class="bold">Back</span></a>
</div>
</div>
<section class="content">
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if ($success) {
?>
<div class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'editConfig');
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
<div class="row">
<div class="col-md-12">
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>');
?> </div>
</div>
</div>
<div class="col-md-12">
<div class="box box-success">
<!-- form start -->
<?php
$attributes = array('class' => 'form-label-left editConfig ', 'name' => 'editConfig', 'id' => 'editConfig');
<div class="form-row" style="margin-top:10px">
<div class="col-md-3">
<label class="col-form-label" for="ConfigId">Configuration ID</label>
<font color="Red">*</font>
<?php
$data = array('name' => 'ConfigId', 'value' => set_value('ConfigId', $ConfigId), 'id' => 'ConfigId', 'class' => 'form-control', 'required' => 'true', 'readonly' => 'true');
echo form_input($data);
?>
</div>
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
<div class="col-md-3">
<label class="col-form-label" for="ConfigName">Configuration Name</label>
<font color="Red">*</font>
<?php
$data = array('name' => 'ConfigName', 'value' => set_value('ConfigName', $ConfigName), 'id' => 'ConfigName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data);
?>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">
<div class="form-group">
<label for="CostName">Configuration ID </label><font color="Red">*</font>
<div class="form-group">
<?php
$data = array('name' => 'ConfigId', 'value' => set_value('ConfigId', $ConfigId), 'id' => 'ConfigId', 'class' => 'form-control', 'required' => 'true', 'readonly' => 'true', 'onclick' => 'al();');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="Description">Configuration Name</label>
<font color="Red">*</font>
<div class="form-group">
<?php
$data = array('name' => 'ConfigName', 'value' => set_value('ConfigName', $ConfigName), 'id' => 'CostName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20'); //'style'=>'text-transform:uppercase;'
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="Remarks">Comments</label>
<font color="Red">*</font>
<div class="form-group">
<?php
$data = array('name' => 'Remarks', 'value' => set_value('Remarks', $Comments), 'id' => 'CostName', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data);
?>
</div>
</div>
</div>
</div>
</div>
<br>
<div col="row">
<div style="text-align:right">
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Configuration</a>
<!-- Modal -->
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Add Configuration</center>
</h4>
</div>
<div class="col-md-3">
<label class="col-form-label" for="Remarks">Comments</label>
<font color="Red">*</font>
<?php
$data = array('name' => 'Remarks', 'value' => set_value('Remarks', $Comments), 'id' => 'Remarks', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data);
?>
</div>
</div>
<!-- Modal Body -->
<div class="modal-body">
<div class="form-row" style="margin-top:10px">
<div class="col-md-12 text-right">
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Configuration</a>
</div>
</div>
<form class="form-horizontal" role="form">
<div class="form-row" style="margin-top:10px">
<div class="col-md-12">
<table id="configtable" class="table table-bordered table-hover responsive-utilities jambo_table" style="background-color:#fff;font-size:12px;">
<thead>
<tr>
<th>S.NO</th>
<th>Config Value</th>
<th>Action</th>
</tr>
</thead>
<tbody id="tempAppend">
<?php if (!empty($master && $child)) {
$index = 0;
foreach ($child as $con) {
$index++;
?>
<input type="hidden" name="DbKey<?php echo $index ?>" id="DbKey<?php echo $index ?>" value="<?php echo $con->Key ?>">
<input type="hidden" name="configVal<?php echo $index ?>" id="configVal<?php echo $index ?>" value="<?php echo $con->ConfigValue ?>">
<tr>
<td><?php echo $index; ?></td>
<td><?php echo $con->ConfigValue; ?></td>
<td><a data-target='#Edit' data-id="<?php echo $index; ?>" data-userid="<?php echo $index; ?>" data-toggle="modal" href="#Edit"><i class="fas fa-pencil-alt" data-toggle="tooltip" title="Click here to view/Edit the Budget details"></i>&nbsp;&nbsp;&nbsp;</a></td>
</tr>
<?php }
} ?>
<input type="hidden" name="txtRowCount" id="txtRowCount" value="<?php echo $index ?>" />
</tbody>
</table>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<div class="form-row text-right" style="margin-top:10px; text-align:right">
<div class="col-md-12 text-right">
<a href="<?php echo base_url() ?>configlisting" class="btn btn-cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Update" />
</div>
</div>
</div>
</div>
</div>
</div>
<input class="form-control" name="AddConfigValue" class="form-control" id="AddConfigValue" type="text">
<!-- Modal For Add Configuration -->
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Add Configuration</center>
</h4>
</div>
</div>
</div>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Configuration Value :
</div>
<div class="col-md-5">
<input class="form-control" name="AddConfigValue" id="AddConfigValue" type="text">
</div>
</div>
</div>
</form>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickAdd" id="tempClickAdd"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add</a>
</div>
</div>
</div>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickAdd" ID="tempClickAdd" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
</div>
</div>
</div>
</div>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="configtable" class="table table-bordered table-hover responsive-utilities jambo_table" style="background-color:#fff;font-size:12px;">
<thead>
<th>S.NO</th>
<th>Config Value</th>
<th>Action</th>
</thead>
<tbody id="tempAppend">
<?php if (!empty($master && $child)) {
$index = 0;
foreach ($child as $con) {
?>
<?php $index = $index + 1; ?>
<input type="hidden" name="DbKey<?php echo $index ?>" id="DbKey<?php echo $index ?>" value="<?php echo $con->Key ?>">
<input type="hidden" name="configVal<?php echo $index ?>" id="configVal<?php echo $index ?>" value="<?php echo $con->ConfigValue ?>">
<tr>
<td><?php echo $index; ?></td>
<td><?php echo $con->ConfigValue; ?></td>
<td><a data-target='#Edit' data-id="<?php echo $index; ?>" data-userid="<?php echo $index; ?>" data-toggle="modal" href="#Edit"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the Budget details"></i>&nbsp;&nbsp;&nbsp;</a></td>
</tr>
<?php
}
}
<!-- Modal For Edit Configuration -->
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Edit Config</center>
</h4>
</div>
?>
<input type="hidden" name="txtRowCount" id="txtRowCount" value="<?php echo $index ?>" />
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
S.NO :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'key', 'value' => set_value('key'), 'id' => 'key', 'class' => 'form-control', 'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
</tbody>
</table>
<!-- Modal For edit -->
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Edit Config</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Config ID :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'Config_ID', 'value' => set_value('Config_ID'), 'id' => 'Config_ID', 'class' => 'form-control', 'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
S.NO :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'key', 'value' => set_value('key'), 'id' => 'key', 'class' => 'form-control', 'readonly' => 'true');
echo form_input($data);
?>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Config Value :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'configValue', 'value' => set_value('configValue'), 'id' => 'configValue', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Config ID :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'Config_ID', 'value' => set_value('Config_ID'), 'id' => 'Config_ID', 'class' => 'form-control', 'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Config Value :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'EditConfigValue', 'value' => set_value('EditConfigValue'), 'id' => 'EditConfigValue', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Update</span></a>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer" style="text-align:right">
<a href="<?php echo base_url() ?>configlisting" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Update" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickUpdate" id="tempClickUpdate"><i class="fa fa-pencil"></i>&nbsp;&nbsp;Update</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
@ -296,153 +273,153 @@ if (!empty($master)) {
</td>
</tr>
</script>
<script>
var index = $('#txtRowCount').val();
var userid = '';
<script>
var index = $('#txtRowCount').val();
var userid = '';
$("#Edit").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
$('#key').val($('#configtable tr:eq(' + userid + ') td:eq(0)').text());
$('#Config_ID').val($('#ConfigId').val());
$('#EditConfigValue').val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
$('#ConfigVal'+userid).val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
$("#Edit").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
$('#key').val($('#configtable tr:eq(' + userid + ') td:eq(0)').text());
$('#Config_ID').val($('#ConfigId').val());
$('#EditConfigValue').val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
$('#ConfigVal' + userid).val($('#configtable tr:eq(' + userid + ') td:eq(1)').text());
});
});
$('.tempClickAdd').click(function() {
$('.tempClickAdd').click(function() {
var cid = $('#ConfigId').val()
var cid = $('#ConfigId').val()
if ($("#AddConfigValue").val() != '-1') {
if ($("#AddConfigValue").val() != '-1') {
$('#AddConfigValue').show();
var ConfigValue = $("#AddConfigValue").val();
$('#AddConfigValue').val('');
$('#AddConfigValue').show();
index = parseInt(index) + 1;
var temp = index;
var ConfigValue = $("#AddConfigValue").val();
$('#AddConfigValue').val('');
var template = jQuery("#tempList").html();
$('#tempAppend').append(_.template(template, {
index: temp,
ConfigValue: ConfigValue,
}));
var theForm = $(".editConfig");
addHidden(theForm, "DbKey" + temp, 0);
addHidden(theForm, "configVal" + temp, ConfigValue);
$('#txtRowCount').val(temp);
//CountRows();
} else {
alert('Please enter all the values');
}
});
index = parseInt(index) + 1;
var temp = index;
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;
'name-as-seen-at-the-server';
input.value = value;
theForm.append(input);
var template = jQuery("#tempList").html();
$('#tempAppend').append(_.template(template, {
index: temp,
ConfigValue: ConfigValue,
}));
var theForm = $(".editConfig");
addHidden(theForm, "DbKey" + temp, 0);
addHidden(theForm, "configVal" + temp, ConfigValue);
$('#txtRowCount').val(temp);
//CountRows();
} else {
alert('Please enter all the values');
}
$('.tempClickEdit').click(function() {
});
if ($("#EditConfigValue").val() != '') {
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;
'name-as-seen-at-the-server';
input.value = value;
theForm.append(input);
}
$('.tempClickEdit').click(function() {
var temp = index;
var ConfigValue = $("#EditConfigValue").val();
//alert(userid);
$('#configtable tr:eq(' + userid + ') td:eq(1)').text(ConfigValue);
//alert($('#hConfigValue'+userid).val());
//$('#hConfigValue'+userid).val(ConfigValue);
$('#Config_ID' + userid).val($('#ConfigId').val());
$('#EditConfigValue' + userid).val(ConfigValue);
$("#configVal" + userid).val(ConfigValue);
} else {
alert('Please enter all the values');
}
});
if ($("#EditConfigValue").val() != '') {
function ConfirmDelete() {
var x = confirm("Are you sure you want to delete?");
if (x)
return true;
else
return false;
var temp = index;
var ConfigValue = $("#EditConfigValue").val();
//alert(userid);
$('#configtable tr:eq(' + userid + ') td:eq(1)').text(ConfigValue);
//alert($('#hConfigValue'+userid).val());
//$('#hConfigValue'+userid).val(ConfigValue);
$('#Config_ID' + userid).val($('#ConfigId').val());
$('#EditConfigValue' + userid).val(ConfigValue);
$("#configVal" + userid).val(ConfigValue);
} else {
alert('Please enter all the values');
}
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
});
function ConfirmDelete() {
var x = confirm("Are you sure you want to delete?");
if (x)
return true;
}
</script>
else
return false;
}
<script>
//var baseurl = "<?php print base_url(); ?>";
$(".editConfig").submit(function(e) {
if (validate()) {
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31 &&
(charCode < 48 || charCode > 57))
return false;
$('#content').loader('show');
$.ajax({
data: $('.editConfig').serialize(),
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configedit",
success: function(data) {
return true;
}
</script>
<script>
//var baseurl = "<?php print base_url(); ?>";
$(".editConfig").submit(function(e) {
if (validate()) {
$('#content').loader('show');
$.ajax({
data: $('.editConfig').serialize(),
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configedit",
success: function(data) {
//alert(data);
if (data) {
$('#content').loader('hide');
//alert(data);
if (data) {
$('#content').loader('hide');
//alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
//window.location = baseurl + 'CostCenter/CostListing';
}
//window.location = baseurl + 'CostCenter/CostListing';
}
});
//$('#content').loader('hide');
}
});
function validate() {
if ($("option:selected", $("#ApprovedBy")).val() == '-1') {
alert('Please Select Approver Names');
return false;
} else {
return true;
}
}
});
//$('#content').loader('hide');
}
</script>
});
function validate() {
if ($("option:selected", $("#ApprovedBy")).val() == '-1') {
alert('Please Select Approver Names');
return false;
} else {
return true;
}
}
</script>

View File

@ -82,6 +82,9 @@ if(!empty($department))
color:#00c0ef ! important;
} */
legend {
margin-left: 0% !important;
}
.pad{
padding-bottom:1%;
}
@ -90,117 +93,96 @@ if(!empty($department))
color:red; background-color:#fff;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center> Edit Department - <?php echo $DepartmentName; ?> Details</center>
</h1>
<ol class="breadcrumb">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>departmentListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</ol>
</section><br/>
<section class="content">
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- general form elements -->
<div class="box">
<!-- form start -->
<div class="row">
<div class="col-md-10 col-md-offset-1"> <!--style="border:3px solid #00d976;;">-->
<form class="form-horizontal" role="form" id="Updatedepartment" action="<?php echo base_url() ?>editdepartment" method="post" role="form"><br/>
<fieldset>
<!-- Form Name -->
<legend>Department Information</legend>
<div class="col-md-2 pad">
<span for="DEPCode">Department Code</span>
<input type="text" name="DEPCode" id="DEPCode" class="form-control" readonly value="<?php echo $DEPCode;?>">
</div>
<div class="col-md-4 pad">
<span for="DepartmentName">Department Name</span><span class="badge">*</span>
<input type="text" name="DepartmentName" id="DepartmentName" class="form-control" required value="<?php echo $DepartmentName;?>">
</div>
<div class="col-md-3 pad">
<span for="HeadDept">Head Department</span>
<select class="form-control required" id="HeadDept" name="HeadDept">
<option value="<?php echo $HeadDept?>"><?php echo $HeadDept?></option>
<?php
if(!empty($depcode))
{
foreach ($depcode as $DC)
{
?>
<option value="<?php echo $DC->DEPCode?>"><?php echo $DC->DEPCode ?> - <?php echo $DC->DepartmentName ?></option>
<?php
}
}
?>
</select>
</div>
<div class="col-md-offset-1 col-md-2">
<div class="form-group">
<span for="Active">Is Active</span> <br>
<input type="checkbox" id="IsActive" name="IsActive" <?php echo $IsActive;?> >
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Department - <?php echo $DepartmentName; ?> Details</h4>
</div>
</div>
<div class="col-6 text-right">
<a class="btn btn-cancel" href="<?php echo base_url(); ?>departmentListing">&nbsp;&nbsp;<span class="bold">Back</span></a>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<form role="form" id="Updatedepartment" action="<?php echo base_url() ?>editdepartment" method="post">
<div class="box-body">
<!-- Department Information -->
<legend>Department Information</legend>
<div class="form-row" style="margin-top:10px">
<div class="col-md-3">
<label class="col-form-label" for="DEPCode">Department Code</label>
<input type="text" name="DEPCode" id="DEPCode" class="form-control" readonly value="<?php echo $DEPCode; ?>">
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-3">
<label class="col-form-label" for="DepartmentName">Department Name<span class="badge">*</span></label>
<input type="text" name="DepartmentName" id="DepartmentName" class="form-control" required value="<?php echo $DepartmentName; ?>">
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-3">
<label class="col-form-label" for="HeadDept">Head Department</label>
<select class="form-control required" id="HeadDept" name="HeadDept">
<option value="<?php echo $HeadDept; ?>"><?php echo $HeadDept; ?></option>
<?php if (!empty($depcode)) {
foreach ($depcode as $DC) { ?>
<option value="<?php echo $DC->DEPCode; ?>"><?php echo $DC->DEPCode . " - " . $DC->DepartmentName; ?></option>
<?php }
} ?>
</select>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-2">
<label class="col-form-label" for="IsActive">Is Active</label><br>
<input type="checkbox" id="IsActive" name="IsActive" <?php echo $IsActive; ?>>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12 text-right">
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red; color: white; margin-right: 15px; width: 80px;" value="Reset" />
<input type="submit" value="Update" class="btn btn-success">
</div>
</div>
</div>
</form>
<div class="row">
<div class="col-md-12">
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) { ?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php }
$success = session()->getFlashdata('success');
if ($success) { ?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-md-3 col-md-offset-9">
<div class="pull-right">
<input type="submit" value="Update" class="btn btn-success">
</div>
</div>
</div> <!-- end card -->
</div><!-- end col -->
</div>
</div>
</fieldset>
</form>
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
</div>
</div>
<div class="col-md-4">
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?> </div>
</div>
</div>
</div>
</section>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
</div>

345
app/Views/expense_list.php Normal file
View File

@ -0,0 +1,345 @@
<style>
.form-group {
padding-bottom: 0%;
}
.Date-filter-form {
display: flex;
align-items: center;
gap: 10px;
/* Adjust the gap as needed */
}
.Date-filter-form input,
.Date-filter-form button {
padding: 5px;
font-size: 14px;
}
.Date-filter-form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
.Date-filter-form button:hover {
background-color: #0056b3;
}
.icon-button {
background: none;
border: none;
cursor: pointer;
color: #007bff;
font-size: 18px;
}
.icon-button:hover {
color: #0056b3;
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Expense List</h4>
</div>
</div>
<div class="col-6 text-right">
<a id="addExpense" class="btn btn-success" data-toggle="modal" href="#expenseModal">Add New Expense</a>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table class="table table-bordered table-hover" id="expense_list_table" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
<th align="right">Created Date</th>
<th align="right">Supplier Name</th>
<th align="right">Cost</th>
<th align="right">GST</th>
<th align="right">Total</th>
<th align="right">Status</th>
<th align="right">payment_method</th>
<th align="right">Action</th> <!-- New column for actions -->
</tr>
</thead>
<tbody>
<?php
if (!empty($expense_list)) {
foreach ($expense_list as $record) {
?>
<tr>
<?php if (date('d-m-Y', strtotime($record['created_on'])) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
$cdate = date('d-m-Y', strtotime($record['created_on']));
} ?>
<td><?php echo $cdate; ?></td>
<td><?php echo $record['SupplierName']; ?></td>
<td><?php echo $record['cost']; ?></td>
<td><?php echo $record['gst']; ?></td>
<td><?php echo $record['total']; ?></td>
<td><?php echo $record['status']; ?></td>
<td><?php echo $record['payment_method']; ?></td>
<td>
<button class="btn btn-primary edit-button" data-id="<?php echo $record['id']; ?>" data-toggle="modal" data-target="#expenseModal">
Edit
</button>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<div id="expenseModal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add Expense</h4>
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<form id="expenseForm" class="form-horizontal" role="form">
<div class="form-group row">
<div class="col-md-5">
<label for="transporterfile" class="col-form-label">Transporter File:</label>
<input type="text" name="transporterfile" id="transporterfile" class="form-control">
</div>
<div class="col-md-1">
</div>
<div class="col-md-5">
<label for="supplierid" class="col-form-label">Supplier ID:</label>
<select name="supplierid" id="supplierid" class="form-control">
<option value="">Select Supplier</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="remarks" class="col-form-label">Remarks:</label>
<input type="text" name="remarks" id="remarks" class="form-control">
</div>
<div class="col-md-1">
</div>
<div class="col-md-5">
<label for="cost" class="col-form-label">Cost:</label>
<input type="number" name="cost" id="cost" class="form-control">
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="gst" class="col-form-label">GST:</label>
<input type="number" name="gst" id="gst" class="form-control">
</div>
<div class="col-md-1">
</div>
<div class="col-md-5">
<label for="total" class="col-form-label">Total:</label>
<input type="number" name="total" id="total" class="form-control">
</div>
</div>
<div class="form-group row">
<div class="col-md-5">
<label for="status" class="col-form-label">Status:</label>
<input type="text" name="status" id="status" class="form-control">
</div>
<div class="col-md-1">
</div>
<div class="col-md-5">
<label for="payment_method" class="col-form-label">Payment Method:</label>
<input type="text" name="payment_method" id="payment_method" class="form-control">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-info waves-effect waves-light tempClick" id="tempClick">Submit</button>
</div>
</div>
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function() {
$(document).on('click', '.edit-button', function() {
var expenseId = $(this).data('id');
$.ajax({
url: '<?php echo base_url().'getExpenseDetails' ?>', // Your PHP script to get expense details
type: 'POST',
data: { id: expenseId },
success: function(response) {
var expense = JSON.parse(response);
// Populate the form with existing data
$('#transporterfile').val(expense.transporterfile);
$('#supplierid').val(expense.supplierid);
$('#remarks').val(expense.remarks);
$('#cost').val(expense.cost);
$('#gst').val(expense.gst);
$('#total').val(expense.total);
$('#status').val(expense.status);
$('#payment_method').val(expense.payment_method);
$('#expenseForm').data('id', expenseId); // Store the ID in the form for later use
},
error: function(xhr, status, error) {
alert('An error occurred: ' + error);
}
});
});
$(document).on('click', '#addExpense', function () {
console.log("1111111111111111111");
var supplier_list = [<?php echo $supplier_list; ?>];
supplier_list[0].forEach(function(supplier) {
// Append each supplier to the dropdown
$('#supplierid').append('<option value="' + supplier.SupplierID + '">' + supplier.SupplierName + '</option>');
});
});
$('#tempClick').on('click', function(e) {
e.preventDefault();
var formData = $('#expenseForm').serialize(); // Serialize form data
$.ajax({
url: '<?php echo base_url().'addExpense' ?>', // Your PHP script to save data
type: 'POST',
data: formData,
success: function(response) {
console.log(response);
if (response) {
// Close the modal
$('#expenseModal').modal('hide');
// Clear the form
$('#expenseForm')[0].reset();
// Refresh the DataTable
window.location.reload();
} else {
// Handle errors here
console.log(response);
// alert(response.message);
}
},
error: function(xhr, status, error) {
// Handle errors here
alert('An error occurred: ' + error);
}
});
});
});
var table = $('#expense_list_table').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
responsive: true, // Responsive table
order: [[0, 'desc']], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
</script>

View File

@ -63,6 +63,7 @@
<script src="<?php echo base_url(); ?>public/new_assets/libs/select2/js/select2.min.js"></script>
<!-- <script src="<?php echo base_url(); ?>public/new_assets/js/validation.js" type="text/javascript"></script> -->
<script>

View File

@ -399,6 +399,9 @@
<a href="<?php echo base_url(); ?>ViewIGR" class="dropdown-item">View Inward Gate Register</a>
</div>
</div>
<div class="dropdown">
<a href="<?php echo base_url(); ?>ListIGR" class="dropdown-item"><i class="ri-file-list-3-line align-middle mr-1"></i> Non IGR / Expense</a>
</div>
</div>
</li>

View File

@ -8,6 +8,7 @@
* @author Kishor Mali
*/
$(document).ready(function(){
var addUserForm = $("#addUser");
@ -16,7 +17,7 @@ $(document).ready(function(){
rules:{
fname :{ required : true },
email : { required : true, email : true, remote : { url : baseURL + "checkEmailExists", type :"post"} },
email : { required : true, email : true, remote : { url : "checkEmailExists", type :"post"} },
password : { required : true },
cpassword : {required : true, equalTo: "#password"},
mobile : { required : true, digits : true },

1368
public/new_assets/js/jquery.validate.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,469 @@
/**
* @author Kishor Mali
*/
$(document).ready(function(){
jQuery.validator.addMethod("notEqualTo", function(value, element)
{
if(value == $('#mobile1').val() && $('#mobile1').val() != "")
{
return false;
}
else
{
return true;
}
},"");
jQuery.validator.addMethod("lessThanBrothers", function(value, element)
{
if(value <= $('#no_of_brothers').val())
{
return true;
}
else
{
return false;
}
},"");
jQuery.validator.addMethod("lessThanSisters", function(value, element)
{
if(value <= $('#no_of_sisters').val())
{
return true;
}
else
{
return false;
}
},"");
jQuery.validator.addMethod("selected", function(value, element)
{
if(value == 0) { return false; }
else { return true; }
},"This field is required.");
jQuery.validator.addMethod("greaterThan", function(value, element)
{
var value = parseFloat(value);
var smaller = parseFloat($("#part_anual_income_from").val());
if(value < smaller)
{ return false; }
else
{ return true; }
},"To Salary is must greater than from.");
jQuery.validator.addMethod("acceptImgExtension", function(value, element)
{
if(value == "")
{
return true;
}
else
{
var extension = (value.substring(value.lastIndexOf('.') + 1)).toLowerCase();
if(extension == 'jpg'|| extension=='png' || extension == "jpeg" || extension == "gif")
{ return true; }
else
{ return false; }
}
}, "");
jQuery.validator.addMethod("acceptDocExtension", function(value, element)
{
if(value == "")
{
return true;
}
else
{
var extension = (value.substring(value.lastIndexOf('.') + 1)).toLowerCase();
if(extension == 'jpg'|| extension=='png' || extension == "jpeg" || extension == "gif")
{ return true; }
else
{ return false; }
}
}, "");
jQuery.validator.addMethod("checkUsername", function(value, element)
{
var response;
var post_url_check_username = baseurl + "user/checkUsernameExist/";
$.ajax({
type: "POST",
url: post_url_check_username,
data: {username : value},
dataType: "json",
async: false
}).done(function(result){
//alert(result.status);
if(result.status == true){
response = false;
}else{
response = true;
}
});
return response;
}, "Username already taken.");
jQuery.validator.addMethod("checkEmailExist", function(value, element)
{
var response = false;
var post_url_check_email = baseurl +"user/checkEmailExist/";
$.ajax({
type: "POST",
url: post_url_check_email,
data: {email : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true){
response = false;
}else{
response = true;
}
});
return response;
}, "Email already taken.");
jQuery.validator.addMethod("checkMobileExist", function(value, element)
{
var response = false;
var post_url_check_mobile = baseurl + "user/checkMobileExist/";
$.ajax({
type: "POST",
url: post_url_check_mobile,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true){
response = false;
}else{
response = true;
}
});
return response;
}, "Mobile number already registered.");
jQuery.validator.addMethod("checkMobileExist2", function(value, element)
{
var response = false;
var post_url_check_mobile2 = baseurl + "user/checkMobileExist2/";
if(value == "")
{
response = true;
}
else
{
$.ajax({
type: "POST",
url: post_url_check_mobile2,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true)
{
response = false;
}else
{
response = true;
}
});
}
return response;
}, "Mobile number already registered.");
jQuery.validator.addMethod("checkPhoneExist", function(value, element)
{
var response = false;
var post_url_check_phone = baseurl +"user/checkPhoneExist/";
if(value == "")
{
response = true;
}
else
{
$.ajax({
type: "POST",
url: post_url_check_phone,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true)
{
response = false;
}else
{
response = true;
}
});
}
return response;
}, "Phone number already registered.");
jQuery.validator.addMethod('checkMobileExist1Same', function(value, element)
{
var response = false;
var post_url_check_phone = baseurl +"profile/checkMobileExist1Same/";
if(value == "")
{
response = true;
}
else
{
$.ajax({
type: "POST",
url: post_url_check_phone,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true)
{
response = false;
}else
{
response = true;
}
});
}
return response;
}, "Mobile number already registered.");
jQuery.validator.addMethod('checkMobileExist2Same', function(value, element)
{
var response = false;
var post_url_check_mobile2 = baseurl + "profile/checkMobileExist2Same/";
if(value == "")
{
response = true;
}
else
{
$.ajax({
type: "POST",
url: post_url_check_mobile2,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true)
{
response = false;
}else
{
response = true;
}
});
}
return response;
}, "Mobile number already registered.");
jQuery.validator.addMethod('checkPhoneExistSame', function(value, element)
{
var response = false;
var post_url_check_mobile2 = baseurl + "profile/checkPhoneExistSame/";
if(value == "")
{
response = true;
}
else
{
$.ajax({
type: "POST",
url: post_url_check_mobile2,
data: {mob : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true)
{
response = false;
}else
{
response = true;
}
});
}
return response;
},"Phone number already registered.");
jQuery.validator.addMethod('checkDateFormat', function(value, element){
var stringPattern = /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$/gm;
if(stringPattern.test(value))
{
return true;
}
else
{
return false;
}
},"Please enter correct date.");
jQuery.validator.addMethod('checkWhiteSpaces', function(value, element){
var stringPattern = /\s/;
if(stringPattern.test(value))
{
return false;
}
else
{
return true;
}
},"Spaces are not allowed in username.");
jQuery.validator.addMethod('checkDateDifference', function(value, element){
var birthYear = parseInt( value.substring(value.lastIndexOf('/') + 1)),
dateNow = new Date(),
dateDiff = dateNow.getFullYear() - birthYear;
if(dateDiff < 17)
{
return false;
}
else
{
return true;
}
},"Please enter less than 18 years of current date.");
/* Make checkboxes work like radio buttons - Start
$('.radio_eating').click(function() {
selectedBox = this.id;
$('.radio_eating').each(function() {
if ( this.id == selectedBox )
{
this.checked = true;
}
else
{
this.checked = false;
};
});
});
$('.radio_drinking').click(function() {
selectedBox = this.id;
$('.radio_drinking').each(function() {
if ( this.id == selectedBox )
{
this.checked = true;
}
else
{
this.checked = false;
};
});
});
$('.radio_smoking').click(function() {
selectedBox = this.id;
$('.radio_smoking').each(function() {
if ( this.id == selectedBox )
{
this.checked = true;
}
else
{
this.checked = false;
};
});
});
*/
/* Physical Disability Textbox enable disable - Start */
$('#physical_status').prop('disabled',true);
$('#chk_physical_status').click(function()
{
if($('#chk_physical_status').prop('checked') == false)
{
$('#physical_status').prop('disabled',true);
}
else
{
$('#physical_status').prop('disabled',false);
}
});
/* Physical Disability Textbox enable disable - End */
jQuery.validator.addMethod("checkEmailExistFranchise", function(value, element)
{
var response = false;
var post_url_check_email_franchise = baseurl +"franchise/franchise/checkEmailExist/";
$.ajax({
type: "POST",
url: post_url_check_email_franchise,
data: {email : value},
dataType: "json",
async: false
}).done(function(result){
if(result.status == true){
response = false;
}else{
response = true;
}
});
return response;
}, "Email already taken.");
});

View File

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 157 KiB

25
vendor/autoload.php vendored
View File

@ -1,25 +0,0 @@
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitb6668d4a545a8f860d35d17ef0fdd011::getLoader();

View File

@ -1,119 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Proxy PHP file generated by Composer
*
* This file includes the referenced bin path (../friendsofphp/php-cs-fixer/php-cs-fixer)
* using a stream wrapper to prevent the shebang from being output on PHP<8
*
* @generated
*/
namespace Composer;
$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
if (PHP_VERSION_ID < 80000) {
if (!class_exists('Composer\BinProxyWrapper')) {
/**
* @internal
*/
final class BinProxyWrapper
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 17);
$this->realpath = realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0;
return (bool) $this->handle;
}
public function stream_read($count)
{
$data = fread($this->handle, $count);
if ($this->position === 0) {
$data = preg_replace('{^#!.*\r?\n}', '', $data);
}
$this->position += strlen($data);
return $data;
}
public function stream_cast($castAs)
{
return $this->handle;
}
public function stream_close()
{
fclose($this->handle);
}
public function stream_lock($operation)
{
return $operation ? flock($this->handle, $operation) : true;
}
public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}
return false;
}
public function stream_tell()
{
return $this->position;
}
public function stream_eof()
{
return feof($this->handle);
}
public function stream_stat()
{
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return true;
}
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
}
}
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/friendsofphp/php-cs-fixer/php-cs-fixer');
}
}
return include __DIR__ . '/..'.'/friendsofphp/php-cs-fixer/php-cs-fixer';

119
vendor/bin/php-parse vendored
View File

@ -1,119 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Proxy PHP file generated by Composer
*
* This file includes the referenced bin path (../nikic/php-parser/bin/php-parse)
* using a stream wrapper to prevent the shebang from being output on PHP<8
*
* @generated
*/
namespace Composer;
$GLOBALS['_composer_bin_dir'] = __DIR__;
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
if (PHP_VERSION_ID < 80000) {
if (!class_exists('Composer\BinProxyWrapper')) {
/**
* @internal
*/
final class BinProxyWrapper
{
private $handle;
private $position;
private $realpath;
public function stream_open($path, $mode, $options, &$opened_path)
{
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
$opened_path = substr($path, 17);
$this->realpath = realpath($opened_path) ?: $opened_path;
$opened_path = $this->realpath;
$this->handle = fopen($this->realpath, $mode);
$this->position = 0;
return (bool) $this->handle;
}
public function stream_read($count)
{
$data = fread($this->handle, $count);
if ($this->position === 0) {
$data = preg_replace('{^#!.*\r?\n}', '', $data);
}
$this->position += strlen($data);
return $data;
}
public function stream_cast($castAs)
{
return $this->handle;
}
public function stream_close()
{
fclose($this->handle);
}
public function stream_lock($operation)
{
return $operation ? flock($this->handle, $operation) : true;
}
public function stream_seek($offset, $whence)
{
if (0 === fseek($this->handle, $offset, $whence)) {
$this->position = ftell($this->handle);
return true;
}
return false;
}
public function stream_tell()
{
return $this->position;
}
public function stream_eof()
{
return feof($this->handle);
}
public function stream_stat()
{
return array();
}
public function stream_set_option($option, $arg1, $arg2)
{
return true;
}
public function url_stat($path, $flags)
{
$path = substr($path, 17);
if (file_exists($path)) {
return stat($path);
}
return false;
}
}
}
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/nikic/php-parser/bin/php-parse');
}
}
return include __DIR__ . '/..'.'/nikic/php-parser/bin/php-parse';

View File

@ -1,190 +0,0 @@
# Changelog
All notable changes to this library will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.8.1](https://github.com/CodeIgniter/coding-standard/compare/v1.8.0...v1.8.1) - 2024-08-05
- Add `keep_annotations` option for `php_unit_attributes`
- Add `php_unit_assert_new_names` fixer
- Bump dependencies
## [v1.8.0](https://github.com/CodeIgniter/coding-standard/compare/v1.7.16...v1.8.0) - 2024-06-16
- Enable rules for PHP 8.1 (#20)
## [v1.7.16](https://github.com/CodeIgniter/coding-standard/compare/v1.7.15...v1.7.16) - 2024-05-18
- Disable `php_unit_attributes` for now
- Fix cs-config to v3.18 for now
- Disable `ordered_attributes` for PHP <8.0
## [v1.7.15](https://github.com/CodeIgniter/coding-standard/compare/v1.7.14...v1.7.15) - 2024-03-24
- Remove deprecated option of `nullable_type_declaration_for_default_null_value`
## [v1.7.14](https://github.com/CodeIgniter/coding-standard/compare/v1.7.13...v1.7.14) - 2024-02-25
- Bump php-cs-fixer to v3.49
- Enable `string_implicit_backslashes` fixer
- Add/remove property-read and property-write
- Enable `phpdoc_list_type`
- Bump to php-cs-fixer v3.50
- Enable `allow_hidden_params` option
- also align `@phpstan-type` and `@phpstan-var`
- Enable `phpdoc_array_type`
## [v1.7.13](https://github.com/CodeIgniter/coding-standard/compare/v1.7.12...v1.7.13) - 2024-01-27
- Update GHA workflows
- Bump to php-cs-fixer v3.47
- Disable all new rules in v3.47
- Apply new options to `phpdoc_align` fixer
- Bump actions/cache from 3 to 4 (#17)
## [v1.7.12](https://github.com/CodeIgniter/coding-standard/compare/v1.7.11...v1.7.12) - 2023-12-29
- Bump php-cs-fixer to v3.43
- Enable other options of `fully_qualified_strict_types`
- Disable `class_keyword`
- Disable option for `statement_indentation`
- Use default for option of `unary_operator_spaces`
## [v1.7.11](https://github.com/CodeIgniter/coding-standard/compare/v1.7.10...v1.7.11) - 2023-10-13
- Bump to php-cs-fixer v3.35
## [v1.7.10](https://github.com/CodeIgniter/coding-standard/compare/v1.7.9...v1.7.10) - 2023-10-01
- Bump to php-cs-fixer v3.34
- Bump to php-cs-fixer v3.30
- Fix tag name in release
## [v1.7.9](https://github.com/CodeIgniter/coding-standard/compare/v1.7.8...v1.7.9) - 2023-09-18
- Update release.yml
- Add `long_to_shorthand_operator` (#13)
- Bump actions/checkout from 3 to 4 (#12)
## [v1.7.8](https://github.com/CodeIgniter/coding-standard/compare/v1.7.7...v1.7.8) - 2023-08-30
- Add `case_sensitive` option to order fixers
## [v1.7.7](https://github.com/CodeIgniter/coding-standard/compare/v1.7.6...v1.7.7) - 2023-08-15
- Specify force option for `php_unit_data_provider_static` fixer
## [v1.7.6](https://github.com/CodeIgniter/coding-standard/compare/v1.7.5...v1.7.6) - 2023-08-15
- Enable 'php_unit_data_provider_static'
- Add new fixers in php-cs-fixer v3.23
- Add `yield_from_array_to_yields`
- Enable `php_unit_data_provider_name`
- Use all available checked tokens for `no_extra_blank_lines`
- Configure `php_unit_data_provider_return_type`
- Remove parallel.timeout in phpstan.neon.dist
## [v1.7.5](https://github.com/CodeIgniter/coding-standard/compare/v1.7.4...v1.7.5) - 2023-07-15
- Configure new fixers in php-cs-fixer v3.20
## [v1.7.4](https://github.com/CodeIgniter/coding-standard/compare/v1.7.3...v1.7.4) - 2023-06-19
- Bump php-cs-fixer to v3.18
- fix: ruleset deprecated on `v3.18` (#10)
- Add case_sensitive option to ordered_class_elements
- Add missing rules
## [v1.7.3](https://github.com/CodeIgniter/coding-standard/compare/v1.7.2...v1.7.3) - 2023-05-05
- Replace `single_space_after_construct` with `single_space_around_construct`
- Remove deprecated `braces` rules
- Bump php-cs-fixer to v3.16
## [v1.7.2](https://github.com/CodeIgniter/coding-standard/compare/v1.7.1...v1.7.2) - 2023-03-05
- Bump php-cs-fixer to v3.14
## [v1.7.1](https://github.com/CodeIgniter/coding-standard/compare/v1.7.0...v1.7.1) - 2022-12-22
- Fix php-cs-fixer version to 3.13.0
## [v1.7.0](https://github.com/CodeIgniter/coding-standard/compare/v1.6.2...v1.7.0) - 2022-11-01
- Bump php-cs-fixer to v3.13
- Add 'case_sensitive' option to 'general_phpdoc_annotation_remove'
- Add 'closure_fn_spacing' option to 'function_declaration'
## [v1.6.2](https://github.com/CodeIgniter/coding-standard/compare/v1.6.1...v1.6.2) - 2022-10-30
- Grouped `runTestsInSeparateProcess`, `runInSeparateProcess`, `preserveGlobalState` together
## [v1.6.1](https://github.com/CodeIgniter/coding-standard/compare/v1.6.0...v1.6.1) - 2022-10-20
- Changed `@internal` description of class CodeIgniter4 to avoid warnings in phpstorm
## [v1.6.0](https://github.com/CodeIgniter/coding-standard/compare/v1.5.0...v1.6.0) - 2022-10-15
- Bump php-cs-fixer version to v3.12 minimum
- Enable `no_useless_concat_operator`
- Update action workflows
## [v1.5.0](https://github.com/CodeIgniter/coding-standard/compare/v1.4.0...v1.5.0) - 2022-09-13
- Enable `ensure_single_space` option of `whitespace_after_comma_in_array`
- Use the `space_multiple_catch` option of `types_spaces`
- Fix multi-lines
- Add `group_to_single_imports` option to `single_import_per_statement`
- chore: fix editorconfig (#4)
- docs: add CONTRIBUTING.md (#3)
- Enable `date_time_create_from_format_call`
- Add options to `new_with_braces`
- Add `order` option to `phpdoc_order`
- Add the `trailing_comma_single_line` option to `function_declaration`
- Enable `curly_braces_position`
- Enable `single_line_comment_spacing`
- Enable `no_trailing_comma_in_singleline`
- Normalize composer.json
- Add "static analysis" Composer keyword (#2)
- Add `inline_constructor_arguments` option to `class_definition`
- Enable `statement_indentation`
- Enable `no_useless_nullsafe_operator`
- Enable `no_multiple_statements_per_line`
- Enable `control_structure_braces`
- Enable `blank_line_between_import_groups`
- Remove deprecated fixers
- Configure `groups` option in `phpdoc_separation` rule
- Bump php-cs-fixer version
## [v1.4.0](https://github.com/CodeIgniter/coding-standard/compare/v1.3.0...v1.4.0) - 2022-02-09
- Permit use of latest php-cs-fixer v3.6.0
## [v1.3.0](https://github.com/CodeIgniter/coding-standard/compare/v1.2.0...v1.3.0) - 2022-01-15
- Fix GHA workflows
- Bump versions
- PHP 7.4 minimum
- friendsofphp/php-cs-fixer v3.4.0
- phpstan/phpstan v1.0 minimum
- Enable `ordered_class_elements` rule
- Enable `global_namespace_import` rule (#1)
- Use `GITHUB_TOKEN` so that secrets can be passed to PRs
## [v1.2.0](https://github.com/CodeIgniter/coding-standard/compare/v1.1.0...v1.2.0) - 2021-10-18
- Bump `friendsofphp/php-cs-fixer` to v3.2 minimum
- Change behavior of `class_attributes_separation` rule
- Add support for new fixers added in php-cs-fixer v3.2.0
- Enable `no_alternative_syntax` rule
## [v1.1.0](https://github.com/CodeIgniter/coding-standard/compare/v1.0.0...v1.1.0) - 2021-08-31
- Bump to `friendsofphp/php-cs-fixer` v3.1.0
- Fix release script
- Bump to `nexusphp/cs-config` v3.3.0
## [v1.0.0](https://github.com/CodeIgniter/coding-standard/releases/tag/v1.0.0) - 2021-08-29
Initial release.

View File

@ -1,10 +0,0 @@
# Contributing to CodeIgniter Coding Standard
CodeIgniter Coding Standard is a community driven project and accepts contributions of
code and documentation from the community.
If you'd like to contribute, please read the [Contributing to CodeIgniter](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/README.md)
guide in the [main repository](https://github.com/codeigniter4/CodeIgniter4).
If you are going to contribute to this repository, please report bugs or send PRs
to this repository instead of the main repository.

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 CodeIgniter Foundation and John Paul E. Balandan, CPA
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,115 +0,0 @@
# CodeIgniter Coding Standard
[![Unit Tests](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpunit.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpunit.yml)
[![Coding Standards](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-coding-standards.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-coding-standards.yml)
[![PHPStan Static Analysis](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpstan.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpstan.yml)
[![PHPStan level](https://img.shields.io/badge/PHPStan-max%20level-brightgreen)](phpstan.neon.dist)
[![Coverage Status](https://coveralls.io/repos/github/CodeIgniter/coding-standard/badge.svg?branch=develop)](https://coveralls.io/github/CodeIgniter/coding-standard?branch=develop)
[![Latest Stable Version](http://poser.pugx.org/codeigniter/coding-standard/v)](https://packagist.org/packages/codeigniter/coding-standard)
[![License](https://img.shields.io/github/license/codeigniter/coding-standard)](LICENSE)
[![Total Downloads](http://poser.pugx.org/codeigniter/coding-standard/downloads)](https://packagist.org/packages/codeigniter/coding-standard)
This library holds the official coding standards of CodeIgniter based
on [PHP CS Fixer][1] and powered by [Nexus CS Config][2].
## Installation
You can add this library as a local, per-project dependency to your project
using [Composer](https://getcomposer.org/):
composer require codeigniter/coding-standard
If you only need this library during development, for instance to run your project's test suite,
then you should add it as a development-time dependency:
composer require --dev codeigniter/coding-standard
## Setup
To start, let us create a `.php-cs-fixer.dist.php` file at the root of your project.
```php
<?php
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
return Factory::create(new CodeIgniter4())->forProjects();
```
This minimal setup will return a default instance of `PhpCsFixer\Config` containing all rules applicable
for the CodeIgniter organization.
Then, in your terminal, run the following command:
```console
$ vendor/bin/php-cs-fixer fix --verbose
```
## Adding License Headers
The default setup will not configure a license header in files. License headers can be especially useful
for library authors to assert copyright. To add license headers in your PHP files, you can simply provide
your name and name of library. Optionally, you can also provide your email and starting license year.
```diff
<?php
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
-return Factory::create(new CodeIgniter4())->forProjects();
+return Factory::create(new CodeIgniter4())->forLibrary(
+ 'CodeIgniter 4 framework',
+ 'CodeIgniter Foundation',
+ 'admin@codeigniter.com',
+ 2021,
+);
```
## Providing Overriding Rules and Options
The list of enabled rules can be found in the [`CodeIgniter\CodingStandard\CodeIgniter4`][3] class. If you
feel the rule is not applicable to you or you want to modify it, you can do so by providing an array of
overriding rules to the second parameter of `Factory::create()`.
Similarly, you can further modify the `PhpCsFixer\Config` instance returned by using the available options.
All available options are fully supported by [Nexus CS Config][2] and abstracted by simply providing an
array of key-value pairs in the third parameter of `Factory::create()`.
```diff
<?php
use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
-return Factory::create(new CodeIgniter4())->forProjects();
+return Factory::create(new CodeIgniter4(), [], [
+ 'usingCache' => false,
+])->forProjects();
```
You can check out this library's own [`.php-cs-fixer.dist.php`][4] for inspiration on how it is done.
For more detailed documentation on all available options, you can check [here][2].
## Contributing
All forms of contributions are welcome!
Since the rules here will be propagated and used within the CodeIgniter organization, all proposed rules
and modifications to existing rules should have a proof-of-concept (POC) PR sent first to
the [CodeIgniter4][5] repository with possible changes to the code styles applied there. Once accepted
there, you can send in a PR here to apply those rules.
## License
This work is open-sourced under the MIT license.
[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://github.com/NexusPHP/cs-config
[3]: src/CodeIgniter4.php
[4]: .php-cs-fixer.dist.php
[5]: https://github.com/codeigniter4/CodeIgniter4

View File

@ -1,49 +0,0 @@
{
"name": "codeigniter/coding-standard",
"description": "Official Coding Standards for CodeIgniter based on PHP CS Fixer",
"license": "MIT",
"type": "library",
"keywords": [
"phpcs",
"static analysis"
],
"authors": [
{
"name": "John Paul E. Balandan, CPA",
"email": "paulbalandan@gmail.com"
}
],
"support": {
"forum": "http://forum.codeigniter.com/",
"source": "https://github.com/CodeIgniter/coding-standard",
"slack": "https://codeigniterchat.slack.com"
},
"require": {
"php": "^8.1",
"ext-tokenizer": "*",
"friendsofphp/php-cs-fixer": "^3.61.1",
"nexusphp/cs-config": "^3.24"
},
"require-dev": {
"nexusphp/tachycardia": "^2.3",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^10.5 || ^11.2"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"CodeIgniter\\CodingStandard\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"CodeIgniter\\CodingStandard\\Tests\\": "tests/"
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
}
}

View File

@ -1,703 +0,0 @@
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) 2021 CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace CodeIgniter\CodingStandard;
use Nexus\CsConfig\Ruleset\AbstractRuleset;
/**
* Defines the ruleset used for the CodeIgniter4 organization.
*
* {@internal Use of this class is not covered by the backward compatibility promise for CodeIgniter4.}
*/
final class CodeIgniter4 extends AbstractRuleset
{
public function __construct()
{
$this->name = 'CodeIgniter4 Coding Standards';
$this->rules = [
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'],
'array_indentation' => true,
'array_push' => true,
'array_syntax' => ['syntax' => 'short'],
'assign_null_coalescing_to_coalesce_equal' => true,
'attribute_empty_parentheses' => false,
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
'||' => 'align_single_space_minimal',
'.=' => 'align_single_space_minimal',
],
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => [
'case',
'continue',
'declare',
'default',
'do',
'exit',
'for',
'foreach',
'goto',
'return',
'switch',
'throw',
'try',
'while',
'yield',
'yield_from',
],
],
'blank_line_between_import_groups' => true,
'blank_lines_before_namespace' => [
'min_line_breaks' => 2,
'max_line_breaks' => 2,
],
'braces_position' => [
'control_structures_opening_brace' => 'same_line',
'functions_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_functions_opening_brace' => 'same_line',
'classes_opening_brace' => 'next_line_unless_newline_at_signature_end',
'anonymous_classes_opening_brace' => 'same_line',
'allow_single_line_empty_anonymous_classes' => true,
'allow_single_line_anonymous_functions' => true,
],
'cast_spaces' => ['space' => 'single'],
'class_attributes_separation' => [
'elements' => [
'const' => 'none',
'property' => 'none',
'method' => 'one',
'trait_import' => 'none',
],
],
'class_definition' => [
'multi_line_extends_each_single_line' => true,
'single_item_single_line' => true,
'single_line' => true,
'space_before_parenthesis' => true,
'inline_constructor_arguments' => true,
],
'class_keyword' => false,
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'comment_to_phpdoc' => [
'ignored_tags' => [
'todo',
'codeCoverageIgnore',
'codeCoverageIgnoreStart',
'codeCoverageIgnoreEnd',
'phpstan-ignore-line',
'phpstan-ignore-next-line',
],
],
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => ['case' => 'lower'],
'control_structure_braces' => true,
'control_structure_continuation_position' => ['position' => 'same_line'],
'date_time_create_from_format_call' => true,
'date_time_immutable' => false,
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => false,
'dir_constant' => true,
'doctrine_annotation_array_assignment' => false,
'doctrine_annotation_braces' => false,
'doctrine_annotation_indentation' => false,
'doctrine_annotation_spaces' => false,
'echo_tag_syntax' => [
'format' => 'short',
'long_function' => 'echo',
'shorten_simple_statements_only' => false,
],
'elseif' => true,
'empty_loop_body' => ['style' => 'braces'],
'empty_loop_condition' => ['style' => 'while'],
'encoding' => true,
'ereg_to_preg' => true,
'error_suppression' => [
'mute_deprecation_error' => true,
'noise_remaining_usages' => false,
'noise_remaining_usages_exclude' => [],
],
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'final_class' => false,
'final_internal_class' => [
'exclude' => ['no-final'],
'include' => ['internal'],
'consider_absent_docblock_as_internal_class' => false,
],
'final_public_method_for_abstract_class' => false,
'fopen_flag_order' => true,
'fopen_flags' => ['b_mode' => true],
'full_opening_tag' => true,
'fully_qualified_strict_types' => [
'import_symbols' => false,
'leading_backslash_in_global_namespace' => false,
'phpdoc_tags' => [
'param',
'phpstan-param',
'phpstan-property',
'phpstan-property-read',
'phpstan-property-write',
'phpstan-return',
'phpstan-var',
'property',
'property-read',
'property-write',
'psalm-param',
'psalm-property',
'psalm-property-read',
'psalm-property-write',
'psalm-return',
'psalm-var',
'return',
'throws',
'var',
],
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'one',
'trailing_comma_single_line' => false,
],
'function_to_constant' => [
'functions' => [
'get_called_class',
'get_class',
'get_class_this',
'php_sapi_name',
'phpversion',
'pi',
],
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author',
'package',
'subpackage',
],
'case_sensitive' => false,
],
'general_phpdoc_tag_rename' => [
'case_sensitive' => false,
'fix_annotation' => true,
'fix_inline' => true,
'replacements' => ['inheritDocs' => 'inheritDoc'],
],
'get_class_to_class_keyword' => false,
'global_namespace_import' => [
'import_constants' => false,
'import_functions' => false,
'import_classes' => true,
],
'group_import' => false,
'header_comment' => false, // false by default
'heredoc_closing_marker' => false,
'heredoc_indentation' => ['indentation' => 'start_plus_one'],
'heredoc_to_nowdoc' => true,
'implode_call' => true,
'include' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'integer_literal_case' => true,
'is_null' => true,
'lambda_not_used_import' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'logical_operators' => true,
'long_to_shorthand_operator' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'mb_str_functions' => false,
'method_argument_space' => [
'keep_multiple_spaces_after_comma' => false,
'on_multiline' => 'ensure_fully_multiline',
'after_heredoc' => false,
'attribute_placement' => 'standalone',
],
'method_chaining_indentation' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'multiline_comment_opening_closing' => true,
'multiline_string_to_heredoc' => false,
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'],
'native_constant_invocation' => false,
'native_function_casing' => true,
'native_function_invocation' => false,
'native_type_declaration_casing' => true,
'new_with_parentheses' => [
'named_class' => true,
'anonymous_class' => true,
],
'no_alias_functions' => ['sets' => ['@all']],
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => ['fix_non_monolithic_code' => false],
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_break_comment' => ['comment_text' => 'no break'],
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'attribute',
'break',
'case',
'continue',
'curly_brace_block',
'default',
'extra',
'parenthesis_brace_block',
'return',
'square_brace_block',
'switch',
'throw',
'use',
],
],
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiple_statements_per_line' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_hidden_params' => true,
'allow_mixed' => true,
'allow_unused_params' => true,
'remove_inheritdoc' => false,
],
'no_trailing_comma_in_singleline' => [
'elements' => [
'arguments',
'array_destructuring',
'array',
'group_import',
],
],
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => true,
'no_unneeded_braces' => ['namespaces' => true],
'no_unneeded_control_parentheses' => [
'statements' => [
'break',
'clone',
'continue',
'echo_print',
'return',
'switch_case',
'yield',
],
],
'no_unneeded_final_method' => ['private_methods' => true],
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => false,
'no_unused_imports' => true,
'no_useless_concat_operator' => ['juggle_simple_strings' => true],
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_useless_return' => true,
'no_useless_sprintf' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'no_whitespace_in_blank_line' => true,
'non_printable_character' => ['use_escape_sequences_in_strings' => true],
'normalize_index_brace' => true,
'not_operator_with_space' => false,
'not_operator_with_successor_space' => true,
'nullable_type_declaration' => ['syntax' => 'question_mark'],
'nullable_type_declaration_for_default_null_value' => true,
'numeric_literal_separator' => false,
'object_operator_without_whitespace' => true,
'octal_notation' => false, // requires 8.1+
'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'],
'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'],
'ordered_class_elements' => [
'order' => [
'use_trait',
'constant',
'property',
'method',
],
'sort_algorithm' => 'none',
'case_sensitive' => false,
],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'function', 'const'],
'case_sensitive' => false,
],
'ordered_interfaces' => false,
'ordered_traits' => false,
'ordered_types' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'alpha',
'case_sensitive' => false,
],
'php_unit_assert_new_names' => true,
'php_unit_attributes' => [
'keep_annotations' => false,
],
'php_unit_construct' => [
'assertions' => [
'assertSame',
'assertEquals',
'assertNotEquals',
'assertNotSame',
],
],
'php_unit_data_provider_name' => [
'prefix' => 'provide',
'suffix' => '',
],
'php_unit_data_provider_return_type' => true,
'php_unit_data_provider_static' => ['force' => true],
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'],
'php_unit_expectation' => ['target' => 'newest'],
'php_unit_fqcn_annotation' => true,
'php_unit_internal_class' => ['types' => ['normal', 'final']],
'php_unit_method_casing' => ['case' => 'camel_case'],
'php_unit_mock' => ['target' => 'newest'],
'php_unit_mock_short_will_return' => true,
'php_unit_namespaced' => ['target' => 'newest'],
'php_unit_no_expectation_annotation' => [
'target' => 'newest',
'use_class_const' => true,
],
'php_unit_set_up_tear_down_visibility' => true,
'php_unit_size_class' => false,
'php_unit_strict' => [
'assertions' => [
'assertAttributeEquals',
'assertAttributeNotEquals',
'assertEquals',
'assertNotEquals',
],
],
'php_unit_test_annotation' => ['style' => 'prefix'],
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
'methods' => [],
],
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => [
'align' => 'vertical',
'spacing' => 1,
'tags' => [
'method',
'param',
'phpstan-assert',
'phpstan-assert-if-true',
'phpstan-assert-if-false',
'phpstan-param',
'phpstan-property',
'phpstan-return',
'phpstan-type',
'phpstan-var',
'property',
'property-read',
'property-write',
'return',
'throws',
'type',
'var',
],
],
'phpdoc_annotation_without_dot' => false,
'phpdoc_array_type' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => [
'tags' => [
'example',
'id',
'internal',
'inheritdoc',
'inheritdocs',
'link',
'source',
'toc',
'tutorial',
],
],
'phpdoc_line_span' => [
'const' => 'multi',
'method' => 'multi',
'property' => 'multi',
],
'phpdoc_list_type' => true,
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => [
'replacements' => [
'type' => 'var',
'link' => 'see',
],
],
'phpdoc_no_empty_return' => false,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => [
'order' => ['param', 'return', 'throws'],
],
'phpdoc_order_by_value' => [
'annotations' => [
'author',
'covers',
'coversNothing',
'dataProvider',
'depends',
'group',
'internal',
'method',
'property',
'property-read',
'property-write',
'requires',
'throws',
'uses',
],
],
'phpdoc_param_order' => false,
'phpdoc_readonly_class_comment_to_keyword' => false,
'phpdoc_return_self_reference' => [
'replacements' => [
'this' => '$this',
'@this' => '$this',
'$self' => 'self',
'@self' => 'self',
'$static' => 'static',
'@static' => 'static',
],
],
'phpdoc_scalar' => [
'types' => [
'boolean',
'callback',
'double',
'integer',
'real',
'str',
],
],
'phpdoc_separation' => [
'groups' => [
['immutable', 'psalm-immutable'],
['param', 'phpstan-param', 'psalm-param'],
['phpstan-pure', 'psalm-pure'],
['readonly', 'psalm-readonly'],
['return', 'phpstan-return', 'psalm-return'],
['runTestsInSeparateProcess', 'runInSeparateProcess', 'preserveGlobalState'],
['template', 'phpstan-template', 'psalm-template'],
['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'],
['phpstan-type', 'psalm-type'],
['var', 'phpstan-var', 'psalm-var'],
],
'skip_unlisted_annotations' => true,
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => false,
'phpdoc_tag_casing' => ['tags' => ['inheritDoc']],
'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']],
'phpdoc_to_comment' => false,
'phpdoc_to_param_type' => false,
'phpdoc_to_property_type' => false,
'phpdoc_to_return_type' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => ['groups' => ['simple', 'alias', 'meta']],
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'alpha',
'case_sensitive' => false,
],
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'psr_autoloading' => ['dir' => null],
'random_api_migration' => [
'replacements' => [
'getrandmax' => 'mt_getrandmax',
'rand' => 'mt_rand',
'srand' => 'mt_srand',
],
],
'regular_callable_call' => true,
'return_assignment' => true,
'return_to_yield_from' => false,
'return_type_declaration' => ['space_before' => 'none'],
'self_accessor' => false,
'self_static_accessor' => true,
'semicolon_after_instruction' => false,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => true,
'simplified_if_return' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => ['elements' => ['const', 'property']],
'single_import_per_statement' => ['group_to_single_imports' => true],
'single_line_after_imports' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']],
'single_line_empty_body' => false,
'single_line_throw' => false,
'single_quote' => ['strings_containing_single_quote_chars' => false],
'single_space_around_construct' => [
'constructs_contain_a_single_space' => ['yield_from'],
'constructs_preceded_by_a_single_space' => ['use_lambda'],
'constructs_followed_by_a_single_space' => [
'abstract',
'as',
'attribute',
'break',
'case',
'catch',
'class',
'clone',
'comment',
'const',
'const_import',
'continue',
'do',
'echo',
'else',
'elseif',
'enum',
'extends',
'final',
'finally',
'for',
'foreach',
'function',
'function_import',
'global',
'goto',
'if',
'implements',
'include',
'include_once',
'instanceof',
'insteadof',
'interface',
'match',
'named_argument',
'namespace',
'new',
'open_tag_with_echo',
'php_doc',
'php_open',
'print',
'private',
'protected',
'public',
'readonly',
'require',
'require_once',
'return',
'static',
'switch',
'throw',
'trait',
'try',
'type_colon',
'use',
'use_lambda',
'use_trait',
'var',
'while',
'yield',
'yield_from',
],
],
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
'spaces_inside_parentheses' => ['space' => 'none'],
'standardize_increment' => true,
'standardize_not_equals' => true,
'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => false],
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'string_implicit_backslashes' => [
'double_quoted' => 'escape',
'heredoc' => 'escape',
'single_quoted' => 'ignore',
],
'string_length_to_empty' => true,
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'switch_continue_to_break' => true,
'ternary_operator_spaces' => true,
'ternary_to_elvis_operator' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['arrays'],
],
'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']],
'types_spaces' => [
'space' => 'none',
'space_multiple_catch' => 'none',
],
'unary_operator_spaces' => ['only_dec_inc' => false],
'use_arrow_functions' => true,
'visibility_required' => ['elements' => ['const', 'method', 'property']],
'void_return' => false, // changes method signature
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yield_from_array_to_yields' => false,
'yoda_style' => [
'equal' => false,
'identical' => null,
'less_and_greater' => false,
'always_move_variable' => false,
],
];
$this->requiredPHPVersion = 80100;
$this->autoActivateIsRiskyAllowed = true;
}
}

View File

@ -1,579 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@ -1,359 +0,0 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}
}

View File

@ -1,21 +0,0 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'3917c79c5052b270641b5a200963dbc2' => $vendorDir . '/kint-php/kint/init.php',
'db356362850385d08a5381de2638b5fd' => $vendorDir . '/mpdf/mpdf/src/functions.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
);

View File

@ -1,10 +0,0 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'org\\bovigo\\vfs\\' => array($vendorDir . '/mikey179/vfsstream/src/main/php'),
);

View File

@ -1,62 +0,0 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'setasign\\Fpdi\\' => array($vendorDir . '/setasign/fpdi/src'),
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
'Symfony\\Polyfill\\Intl\\Grapheme\\' => array($vendorDir . '/symfony/polyfill-intl-grapheme'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'),
'Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
'Symfony\\Component\\Stopwatch\\' => array($vendorDir . '/symfony/stopwatch'),
'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'React\\Stream\\' => array($vendorDir . '/react/stream/src'),
'React\\Socket\\' => array($vendorDir . '/react/socket/src'),
'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
'React\\EventLoop\\' => array($vendorDir . '/react/event-loop/src'),
'React\\Dns\\' => array($vendorDir . '/react/dns/src'),
'React\\ChildProcess\\' => array($vendorDir . '/react/child-process/src'),
'React\\Cache\\' => array($vendorDir . '/react/cache/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Predis\\' => array($vendorDir . '/predis/predis/src'),
'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'),
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
'PhpCsFixer\\' => array($vendorDir . '/friendsofphp/php-cs-fixer/src'),
'Nexus\\CsConfig\\' => array($vendorDir . '/nexusphp/cs-config/src'),
'Mpdf\\PsrLogAwareTrait\\' => array($vendorDir . '/mpdf/psr-log-aware-trait/src'),
'Mpdf\\PsrHttpMessageShim\\' => array($vendorDir . '/mpdf/psr-http-message-shim/src'),
'Mpdf\\' => array($vendorDir . '/mpdf/mpdf/src'),
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
'Laminas\\Escaper\\' => array($vendorDir . '/laminas/laminas-escaper/src'),
'Kint\\' => array($vendorDir . '/kint-php/kint/src'),
'Fidry\\CpuCoreCounter\\' => array($vendorDir . '/fidry/cpu-core-counter/src'),
'Faker\\' => array($vendorDir . '/fakerphp/faker/src/Faker'),
'Evenement\\' => array($vendorDir . '/evenement/evenement/src'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
'CodeIgniter\\CodingStandard\\' => array($vendorDir . '/codeigniter/coding-standard/src'),
'CodeIgniter\\' => array($baseDir . '/system'),
'Clue\\React\\NDJson\\' => array($vendorDir . '/clue/ndjson-react/src'),
);

View File

@ -1,50 +0,0 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb6668d4a545a8f860d35d17ef0fdd011
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitb6668d4a545a8f860d35d17ef0fdd011', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb6668d4a545a8f860d35d17ef0fdd011', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb6668d4a545a8f860d35d17ef0fdd011::getInitializer($loader));
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInitb6668d4a545a8f860d35d17ef0fdd011::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,761 +0,0 @@
<?php return array(
'root' => array(
'name' => 'codeigniter4/framework',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'dea6b204d35302eab4f6049ea7307d19804ef2ba',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'clue/ndjson-react' => array(
'pretty_version' => 'v1.3.0',
'version' => '1.3.0.0',
'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0',
'type' => 'library',
'install_path' => __DIR__ . '/../clue/ndjson-react',
'aliases' => array(),
'dev_requirement' => true,
),
'codeigniter/coding-standard' => array(
'pretty_version' => 'v1.8.1',
'version' => '1.8.1.0',
'reference' => '2c16682b4a3754bc6694fef1056f686f32298ee3',
'type' => 'library',
'install_path' => __DIR__ . '/../codeigniter/coding-standard',
'aliases' => array(),
'dev_requirement' => true,
),
'codeigniter4/framework' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'dea6b204d35302eab4f6049ea7307d19804ef2ba',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'composer/pcre' => array(
'pretty_version' => '3.3.0',
'version' => '3.3.0.0',
'reference' => '1637e067347a0c40bbb1e3cd786b20dcab556a81',
'type' => 'library',
'install_path' => __DIR__ . '/./pcre',
'aliases' => array(),
'dev_requirement' => true,
),
'composer/semver' => array(
'pretty_version' => '3.4.2',
'version' => '3.4.2.0',
'reference' => 'c51258e759afdb17f1fd1fe83bc12baaef6309d6',
'type' => 'library',
'install_path' => __DIR__ . '/./semver',
'aliases' => array(),
'dev_requirement' => true,
),
'composer/xdebug-handler' => array(
'pretty_version' => '3.0.5',
'version' => '3.0.5.0',
'reference' => '6c1925561632e83d60a44492e0b344cf48ab85ef',
'type' => 'library',
'install_path' => __DIR__ . '/./xdebug-handler',
'aliases' => array(),
'dev_requirement' => true,
),
'evenement/evenement' => array(
'pretty_version' => 'v3.0.2',
'version' => '3.0.2.0',
'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc',
'type' => 'library',
'install_path' => __DIR__ . '/../evenement/evenement',
'aliases' => array(),
'dev_requirement' => true,
),
'fakerphp/faker' => array(
'pretty_version' => 'v1.23.1',
'version' => '1.23.1.0',
'reference' => 'bfb4fe148adbf78eff521199619b93a52ae3554b',
'type' => 'library',
'install_path' => __DIR__ . '/../fakerphp/faker',
'aliases' => array(),
'dev_requirement' => true,
),
'fidry/cpu-core-counter' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'reference' => 'f92996c4d5c1a696a6a970e20f7c4216200fcc42',
'type' => 'library',
'install_path' => __DIR__ . '/../fidry/cpu-core-counter',
'aliases' => array(),
'dev_requirement' => true,
),
'friendsofphp/php-cs-fixer' => array(
'pretty_version' => 'v3.62.0',
'version' => '3.62.0.0',
'reference' => '627692f794d35c43483f34b01d94740df2a73507',
'type' => 'application',
'install_path' => __DIR__ . '/../friendsofphp/php-cs-fixer',
'aliases' => array(),
'dev_requirement' => true,
),
'kint-php/kint' => array(
'pretty_version' => '5.1.1',
'version' => '5.1.1.0',
'reference' => '8c5ec370c3382ceae0b88e91f9bbb00e6bb4f93b',
'type' => 'library',
'install_path' => __DIR__ . '/../kint-php/kint',
'aliases' => array(),
'dev_requirement' => true,
),
'laminas/laminas-escaper' => array(
'pretty_version' => '2.13.0',
'version' => '2.13.0.0',
'reference' => 'af459883f4018d0f8a0c69c7a209daef3bf973ba',
'type' => 'library',
'install_path' => __DIR__ . '/../laminas/laminas-escaper',
'aliases' => array(),
'dev_requirement' => false,
),
'maennchen/zipstream-php' => array(
'pretty_version' => '3.1.0',
'version' => '3.1.0.0',
'reference' => 'b8174494eda667f7d13876b4a7bfef0f62a7c0d1',
'type' => 'library',
'install_path' => __DIR__ . '/../maennchen/zipstream-php',
'aliases' => array(),
'dev_requirement' => false,
),
'markbaker/complex' => array(
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'reference' => '95c56caa1cf5c766ad6d65b6344b807c1e8405b9',
'type' => 'library',
'install_path' => __DIR__ . '/../markbaker/complex',
'aliases' => array(),
'dev_requirement' => false,
),
'markbaker/matrix' => array(
'pretty_version' => '3.0.1',
'version' => '3.0.1.0',
'reference' => '728434227fe21be27ff6d86621a1b13107a2562c',
'type' => 'library',
'install_path' => __DIR__ . '/../markbaker/matrix',
'aliases' => array(),
'dev_requirement' => false,
),
'mikey179/vfsstream' => array(
'pretty_version' => 'v1.6.11',
'version' => '1.6.11.0',
'reference' => '17d16a85e6c26ce1f3e2fa9ceeacdc2855db1e9f',
'type' => 'library',
'install_path' => __DIR__ . '/../mikey179/vfsstream',
'aliases' => array(),
'dev_requirement' => true,
),
'mpdf/mpdf' => array(
'pretty_version' => 'v8.2.4',
'version' => '8.2.4.0',
'reference' => '9e3ff91606fed11cd58a130eabaaf60e56fdda88',
'type' => 'library',
'install_path' => __DIR__ . '/../mpdf/mpdf',
'aliases' => array(),
'dev_requirement' => false,
),
'mpdf/psr-http-message-shim' => array(
'pretty_version' => 'v2.0.1',
'version' => '2.0.1.0',
'reference' => 'f25a0153d645e234f9db42e5433b16d9b113920f',
'type' => 'library',
'install_path' => __DIR__ . '/../mpdf/psr-http-message-shim',
'aliases' => array(),
'dev_requirement' => false,
),
'mpdf/psr-log-aware-trait' => array(
'pretty_version' => 'v3.0.0',
'version' => '3.0.0.0',
'reference' => 'a633da6065e946cc491e1c962850344bb0bf3e78',
'type' => 'library',
'install_path' => __DIR__ . '/../mpdf/psr-log-aware-trait',
'aliases' => array(),
'dev_requirement' => false,
),
'myclabs/deep-copy' => array(
'pretty_version' => '1.12.0',
'version' => '1.12.0.0',
'reference' => '3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c',
'type' => 'library',
'install_path' => __DIR__ . '/../myclabs/deep-copy',
'aliases' => array(),
'dev_requirement' => false,
),
'nexusphp/cs-config' => array(
'pretty_version' => 'v3.24.0',
'version' => '3.24.0.0',
'reference' => 'fd0fdb458cbf42ba636a2ed218530b335421f33f',
'type' => 'library',
'install_path' => __DIR__ . '/../nexusphp/cs-config',
'aliases' => array(),
'dev_requirement' => true,
),
'nikic/php-parser' => array(
'pretty_version' => 'v5.1.0',
'version' => '5.1.0.0',
'reference' => '683130c2ff8c2739f4822ff7ac5c873ec529abd1',
'type' => 'library',
'install_path' => __DIR__ . '/../nikic/php-parser',
'aliases' => array(),
'dev_requirement' => true,
),
'paragonie/random_compat' => array(
'pretty_version' => 'v9.99.100',
'version' => '9.99.100.0',
'reference' => '996434e5492cb4c3edcb9168db6fbb1359ef965a',
'type' => 'library',
'install_path' => __DIR__ . '/../paragonie/random_compat',
'aliases' => array(),
'dev_requirement' => false,
),
'phar-io/manifest' => array(
'pretty_version' => '2.0.4',
'version' => '2.0.4.0',
'reference' => '54750ef60c58e43759730615a392c31c80e23176',
'type' => 'library',
'install_path' => __DIR__ . '/../phar-io/manifest',
'aliases' => array(),
'dev_requirement' => true,
),
'phar-io/version' => array(
'pretty_version' => '3.2.1',
'version' => '3.2.1.0',
'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
'type' => 'library',
'install_path' => __DIR__ . '/../phar-io/version',
'aliases' => array(),
'dev_requirement' => true,
),
'phpoffice/phpspreadsheet' => array(
'pretty_version' => '2.2.2',
'version' => '2.2.2.0',
'reference' => 'ffbcee68069b073bff07a71eb321dcd9f2763513',
'type' => 'library',
'install_path' => __DIR__ . '/../phpoffice/phpspreadsheet',
'aliases' => array(),
'dev_requirement' => false,
),
'phpunit/php-code-coverage' => array(
'pretty_version' => '10.1.15',
'version' => '10.1.15.0',
'reference' => '5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-file-iterator' => array(
'pretty_version' => '4.1.0',
'version' => '4.1.0.0',
'reference' => 'a95037b6d9e608ba092da1b23931e537cadc3c3c',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-invoker' => array(
'pretty_version' => '4.0.0',
'version' => '4.0.0.0',
'reference' => 'f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-invoker',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-text-template' => array(
'pretty_version' => '3.0.1',
'version' => '3.0.1.0',
'reference' => '0c7b06ff49e3d5072f057eb1fa59258bf287a748',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-text-template',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-timer' => array(
'pretty_version' => '6.0.0',
'version' => '6.0.0.0',
'reference' => 'e2a2d67966e740530f4a3343fe2e030ffdc1161d',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/php-timer',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/phpunit' => array(
'pretty_version' => '10.5.30',
'version' => '10.5.30.0',
'reference' => 'b15524febac0153876b4ba9aab3326c2ee94c897',
'type' => 'library',
'install_path' => __DIR__ . '/../phpunit/phpunit',
'aliases' => array(),
'dev_requirement' => true,
),
'predis/predis' => array(
'pretty_version' => 'v2.2.2',
'version' => '2.2.2.0',
'reference' => 'b1d3255ed9ad4d7254f9f9bba386c99f4bb983d1',
'type' => 'library',
'install_path' => __DIR__ . '/../predis/predis',
'aliases' => array(),
'dev_requirement' => true,
),
'psr/container' => array(
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',
'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/container',
'aliases' => array(),
'dev_requirement' => true,
),
'psr/event-dispatcher' => array(
'pretty_version' => '1.0.0',
'version' => '1.0.0.0',
'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/event-dispatcher',
'aliases' => array(),
'dev_requirement' => true,
),
'psr/event-dispatcher-implementation' => array(
'dev_requirement' => true,
'provided' => array(
0 => '1.0',
),
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-client',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-factory' => array(
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-factory',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-message' => array(
'pretty_version' => '2.0',
'version' => '2.0.0.0',
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-message',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/log' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/log',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/log-implementation' => array(
'dev_requirement' => true,
'provided' => array(
0 => '1.0|2.0|3.0',
),
),
'psr/simple-cache' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/simple-cache',
'aliases' => array(),
'dev_requirement' => false,
),
'react/cache' => array(
'pretty_version' => 'v1.2.0',
'version' => '1.2.0.0',
'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b',
'type' => 'library',
'install_path' => __DIR__ . '/../react/cache',
'aliases' => array(),
'dev_requirement' => true,
),
'react/child-process' => array(
'pretty_version' => 'v0.6.5',
'version' => '0.6.5.0',
'reference' => 'e71eb1aa55f057c7a4a0d08d06b0b0a484bead43',
'type' => 'library',
'install_path' => __DIR__ . '/../react/child-process',
'aliases' => array(),
'dev_requirement' => true,
),
'react/dns' => array(
'pretty_version' => 'v1.13.0',
'version' => '1.13.0.0',
'reference' => 'eb8ae001b5a455665c89c1df97f6fb682f8fb0f5',
'type' => 'library',
'install_path' => __DIR__ . '/../react/dns',
'aliases' => array(),
'dev_requirement' => true,
),
'react/event-loop' => array(
'pretty_version' => 'v1.5.0',
'version' => '1.5.0.0',
'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354',
'type' => 'library',
'install_path' => __DIR__ . '/../react/event-loop',
'aliases' => array(),
'dev_requirement' => true,
),
'react/promise' => array(
'pretty_version' => 'v3.2.0',
'version' => '3.2.0.0',
'reference' => '8a164643313c71354582dc850b42b33fa12a4b63',
'type' => 'library',
'install_path' => __DIR__ . '/../react/promise',
'aliases' => array(),
'dev_requirement' => true,
),
'react/socket' => array(
'pretty_version' => 'v1.16.0',
'version' => '1.16.0.0',
'reference' => '23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1',
'type' => 'library',
'install_path' => __DIR__ . '/../react/socket',
'aliases' => array(),
'dev_requirement' => true,
),
'react/stream' => array(
'pretty_version' => 'v1.4.0',
'version' => '1.4.0.0',
'reference' => '1e5b0acb8fe55143b5b426817155190eb6f5b18d',
'type' => 'library',
'install_path' => __DIR__ . '/../react/stream',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/cli-parser' => array(
'pretty_version' => '2.0.1',
'version' => '2.0.1.0',
'reference' => 'c34583b87e7b7a8055bf6c450c2c77ce32a24084',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/cli-parser',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/code-unit' => array(
'pretty_version' => '2.0.0',
'version' => '2.0.0.0',
'reference' => 'a81fee9eef0b7a76af11d121767abc44c104e503',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/code-unit',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/code-unit-reverse-lookup' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => '5e3a687f7d8ae33fb362c5c0743794bbb2420a1d',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/comparator' => array(
'pretty_version' => '5.0.2',
'version' => '5.0.2.0',
'reference' => '2d3e04c3b4c1e84a5e7382221ad8883c8fbc4f53',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/comparator',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/complexity' => array(
'pretty_version' => '3.2.0',
'version' => '3.2.0.0',
'reference' => '68ff824baeae169ec9f2137158ee529584553799',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/complexity',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/diff' => array(
'pretty_version' => '5.1.1',
'version' => '5.1.1.0',
'reference' => 'c41e007b4b62af48218231d6c2275e4c9b975b2e',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/diff',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/environment' => array(
'pretty_version' => '6.1.0',
'version' => '6.1.0.0',
'reference' => '8074dbcd93529b357029f5cc5058fd3e43666984',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/environment',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/exporter' => array(
'pretty_version' => '5.1.2',
'version' => '5.1.2.0',
'reference' => '955288482d97c19a372d3f31006ab3f37da47adf',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/exporter',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/global-state' => array(
'pretty_version' => '6.0.2',
'version' => '6.0.2.0',
'reference' => '987bafff24ecc4c9ac418cab1145b96dd6e9cbd9',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/global-state',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/lines-of-code' => array(
'pretty_version' => '2.0.2',
'version' => '2.0.2.0',
'reference' => '856e7f6a75a84e339195d48c556f23be2ebf75d0',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/lines-of-code',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/object-enumerator' => array(
'pretty_version' => '5.0.0',
'version' => '5.0.0.0',
'reference' => '202d0e344a580d7f7d04b3fafce6933e59dae906',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/object-enumerator',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/object-reflector' => array(
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => '24ed13d98130f0e7122df55d06c5c4942a577957',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/object-reflector',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/recursion-context' => array(
'pretty_version' => '5.0.0',
'version' => '5.0.0.0',
'reference' => '05909fb5bc7df4c52992396d0116aed689f93712',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/recursion-context',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/type' => array(
'pretty_version' => '4.0.0',
'version' => '4.0.0.0',
'reference' => '462699a16464c3944eefc02ebdd77882bd3925bf',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/type',
'aliases' => array(),
'dev_requirement' => true,
),
'sebastian/version' => array(
'pretty_version' => '4.0.1',
'version' => '4.0.1.0',
'reference' => 'c51fa83a5d8f43f1402e3f32a005e6262244ef17',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/version',
'aliases' => array(),
'dev_requirement' => true,
),
'setasign/fpdi' => array(
'pretty_version' => 'v2.6.0',
'version' => '2.6.0.0',
'reference' => 'a6db878129ec6c7e141316ee71872923e7f1b7ad',
'type' => 'library',
'install_path' => __DIR__ . '/../setasign/fpdi',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/console' => array(
'pretty_version' => 'v7.1.3',
'version' => '7.1.3.0',
'reference' => 'cb1dcb30ebc7005c29864ee78adb47b5fb7c3cd9',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/console',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => '0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/event-dispatcher' => array(
'pretty_version' => 'v7.1.1',
'version' => '7.1.1.0',
'reference' => '9fa7f7a21beb22a39a8f3f28618b29e50d7a55a7',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/event-dispatcher',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/event-dispatcher-contracts' => array(
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => '8f93aec25d41b72493c6ddff14e916177c9efc50',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/event-dispatcher-contracts',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/event-dispatcher-implementation' => array(
'dev_requirement' => true,
'provided' => array(
0 => '2.0|3.0',
),
),
'symfony/filesystem' => array(
'pretty_version' => 'v7.1.2',
'version' => '7.1.2.0',
'reference' => '92a91985250c251de9b947a14bb2c9390b1a562c',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/filesystem',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/finder' => array(
'pretty_version' => 'v7.1.3',
'version' => '7.1.3.0',
'reference' => '717c6329886f32dc65e27461f80f2a465412fdca',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/finder',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/options-resolver' => array(
'pretty_version' => 'v7.1.1',
'version' => '7.1.1.0',
'reference' => '47aa818121ed3950acd2b58d1d37d08a94f9bf55',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/options-resolver',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-ctype' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => '0424dff1c58f028c451efff2045f5d92410bd540',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-intl-grapheme' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => '64647a7c30b2283f5d49b874d84a18fc22054b7a',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-intl-normalizer' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => 'a95281b0be0d9ab48050ebd988b967875cdb9fdb',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => 'fd22ab50000ef01661e2a31d850ebaa297f8e03c',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-php80' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => '77fa7995ac1b21ab60769b7323d600a991a90433',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php80',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-php81' => array(
'pretty_version' => 'v1.30.0',
'version' => '1.30.0.0',
'reference' => '3fb075789fb91f9ad9af537c4012d523085bd5af',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-php81',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/process' => array(
'pretty_version' => 'v7.1.3',
'version' => '7.1.3.0',
'reference' => '7f2f542c668ad6c313dc4a5e9c3321f733197eca',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/process',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/service-contracts' => array(
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => 'bd1d9e59a81d8fa4acdcea3f617c581f7475a80f',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/service-contracts',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/stopwatch' => array(
'pretty_version' => 'v7.1.1',
'version' => '7.1.1.0',
'reference' => '5b75bb1ac2ba1b9d05c47fc4b3046a625377d23d',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/stopwatch',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/string' => array(
'pretty_version' => 'v7.1.3',
'version' => '7.1.3.0',
'reference' => 'ea272a882be7f20cad58d5d78c215001617b7f07',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/string',
'aliases' => array(),
'dev_requirement' => true,
),
'theseer/tokenizer' => array(
'pretty_version' => '1.2.3',
'version' => '1.2.3.0',
'reference' => '737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2',
'type' => 'library',
'install_path' => __DIR__ . '/../theseer/tokenizer',
'aliases' => array(),
'dev_requirement' => true,
),
),
);

View File

@ -1,19 +0,0 @@
Copyright (C) 2021 Composer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,189 +0,0 @@
composer/pcre
=============
PCRE wrapping library that offers type-safe `preg_*` replacements.
This library gives you a way to ensure `preg_*` functions do not fail silently, returning
unexpected `null`s that may not be handled.
As of 3.0 this library enforces [`PREG_UNMATCHED_AS_NULL`](#preg_unmatched_as_null) usage
for all matching and replaceCallback functions, [read more below](#preg_unmatched_as_null)
to understand the implications.
It thus makes it easier to work with static analysis tools like PHPStan or Psalm as it
simplifies and reduces the possible return values from all the `preg_*` functions which
are quite packed with edge cases. As of v2.2.0 / v3.2.0 the library also comes with a
[PHPStan extension](#phpstan-extension) for parsing regular expressions and giving you even better output types.
This library is a thin wrapper around `preg_*` functions with [some limitations](#restrictions--limitations).
If you are looking for a richer API to handle regular expressions have a look at
[rawr/t-regx](https://packagist.org/packages/rawr/t-regx) instead.
[![Continuous Integration](https://github.com/composer/pcre/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/pcre/actions)
Installation
------------
Install the latest version with:
```bash
$ composer require composer/pcre
```
Requirements
------------
* PHP 7.4.0 is required for 3.x versions
* PHP 7.2.0 is required for 2.x versions
* PHP 5.3.2 is required for 1.x versions
Basic usage
-----------
Instead of:
```php
if (preg_match('{fo+}', $string, $matches)) { ... }
if (preg_match('{fo+}', $string, $matches, PREG_OFFSET_CAPTURE)) { ... }
if (preg_match_all('{fo+}', $string, $matches)) { ... }
$newString = preg_replace('{fo+}', 'bar', $string);
$newString = preg_replace_callback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = preg_replace_callback_array(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = preg_grep('{[a-z]}', $elements);
$array = preg_split('{[a-z]+}', $string);
```
You can now call these on the `Preg` class:
```php
use Composer\Pcre\Preg;
if (Preg::match('{fo+}', $string, $matches)) { ... }
if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... }
if (Preg::matchAll('{fo+}', $string, $matches)) { ... }
$newString = Preg::replace('{fo+}', 'bar', $string);
$newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string);
$newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string);
$filtered = Preg::grep('{[a-z]}', $elements);
$array = Preg::split('{[a-z]+}', $string);
```
The main difference is if anything fails to match/replace/.., it will throw a `Composer\Pcre\PcreException`
instead of returning `null` (or false in some cases), so you can now use the return values safely relying on
the fact that they can only be strings (for replace), ints (for match) or arrays (for grep/split).
Additionally the `Preg` class provides match methods that return `bool` rather than `int`, for stricter type safety
when the number of pattern matches is not useful:
```php
use Composer\Pcre\Preg;
if (Preg::isMatch('{fo+}', $string, $matches)) // bool
if (Preg::isMatchAll('{fo+}', $string, $matches)) // bool
```
Finally the `Preg` class provides a few `*StrictGroups` method variants that ensure match groups
are always present and thus non-nullable, making it easier to write type-safe code:
```php
use Composer\Pcre\Preg;
// $matches is guaranteed to be an array of strings, if a subpattern does not match and produces a null it will throw
if (Preg::matchStrictGroups('{fo+}', $string, $matches))
if (Preg::matchAllStrictGroups('{fo+}', $string, $matches))
```
**Note:** This is generally safe to use as long as you do not have optional subpatterns (i.e. `(something)?`
or `(something)*` or branches with a `|` that result in some groups not being matched at all).
A subpattern that can match an empty string like `(.*)` is **not** optional, it will be present as an
empty string in the matches. A non-matching subpattern, even if optional like `(?:foo)?` will anyway not be present in
matches so it is also not a problem to use these with `*StrictGroups` methods.
If you would prefer a slightly more verbose usage, replacing by-ref arguments by result objects, you can use the `Regex` class:
```php
use Composer\Pcre\Regex;
// this is useful when you are just interested in knowing if something matched
// as it returns a bool instead of int(1/0) for match
$bool = Regex::isMatch('{fo+}', $string);
$result = Regex::match('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchWithOffsets('{fo+}', $string);
if ($result->matched) { something($result->matches); }
$result = Regex::matchAll('{fo+}', $string);
if ($result->matched && $result->count > 3) { something($result->matches); }
$newString = Regex::replace('{fo+}', 'bar', $string)->result;
$newString = Regex::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string)->result;
$newString = Regex::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string)->result;
```
Note that `preg_grep` and `preg_split` are only callable via the `Preg` class as they do not have
complex return types warranting a specific result object.
See the [MatchResult](src/MatchResult.php), [MatchWithOffsetsResult](src/MatchWithOffsetsResult.php), [MatchAllResult](src/MatchAllResult.php),
[MatchAllWithOffsetsResult](src/MatchAllWithOffsetsResult.php), and [ReplaceResult](src/ReplaceResult.php) class sources for more details.
Restrictions / Limitations
--------------------------
Due to type safety requirements a few restrictions are in place.
- matching using `PREG_OFFSET_CAPTURE` is made available via `matchWithOffsets` and `matchAllWithOffsets`.
You cannot pass the flag to `match`/`matchAll`.
- `Preg::split` will also reject `PREG_SPLIT_OFFSET_CAPTURE` and you should use `splitWithOffsets`
instead.
- `matchAll` rejects `PREG_SET_ORDER` as it also changes the shape of the returned matches. There
is no alternative provided as you can fairly easily code around it.
- `preg_filter` is not supported as it has a rather crazy API, most likely you should rather
use `Preg::grep` in combination with some loop and `Preg::replace`.
- `replace`, `replaceCallback` and `replaceCallbackArray` do not support an array `$subject`,
only simple strings.
- As of 2.0, the library always uses `PREG_UNMATCHED_AS_NULL` for matching, which offers [much
saner/more predictable results](#preg_unmatched_as_null). As of 3.0 the flag is also set for
`replaceCallback` and `replaceCallbackArray`.
#### PREG_UNMATCHED_AS_NULL
As of 2.0, this library always uses PREG_UNMATCHED_AS_NULL for all `match*` and `isMatch*`
functions. As of 3.0 it is also done for `replaceCallback` and `replaceCallbackArray`.
This means your matches will always contain all matching groups, either as null if unmatched
or as string if it matched.
The advantages in clarity and predictability are clearer if you compare the two outputs of
running this with and without PREG_UNMATCHED_AS_NULL in $flags:
```php
preg_match('/(a)(b)*(c)(d)*/', 'ac', $matches, $flags);
```
| no flag | PREG_UNMATCHED_AS_NULL |
| --- | --- |
| array (size=4) | array (size=5) |
| 0 => string 'ac' (length=2) | 0 => string 'ac' (length=2) |
| 1 => string 'a' (length=1) | 1 => string 'a' (length=1) |
| 2 => string '' (length=0) | 2 => null |
| 3 => string 'c' (length=1) | 3 => string 'c' (length=1) |
| | 4 => null |
| group 2 (any unmatched group preceding one that matched) is set to `''`. You cannot tell if it matched an empty string or did not match at all | group 2 is `null` when unmatched and a string if it matched, easy to check for |
| group 4 (any optional group without a matching one following) is missing altogether. So you have to check with `isset()`, but really you want `isset($m[4]) && $m[4] !== ''` for safety unless you are very careful to check that a non-optional group follows it | group 4 is always set, and null in this case as there was no match, easy to check for with `$m[4] !== null` |
PHPStan Extension
-----------------
To use the PHPStan extension if you do not use `phpstan/extension-installer` you can include `vendor/composer/pcre/extension.neon` in your PHPStan config.
The extension provides much better type information for $matches as well as regex validation where possible.
License
-------
composer/pcre is licensed under the MIT License, see the LICENSE file for details.

View File

@ -1,54 +0,0 @@
{
"name": "composer/pcre",
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"type": "library",
"license": "MIT",
"keywords": [
"pcre",
"regex",
"preg",
"regular expression"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"require": {
"php": "^7.4 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8 || ^9",
"phpstan/phpstan": "^1.11.10",
"phpstan/phpstan-strict-rules": "^1.1"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\Pcre\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
},
"phpstan": {
"includes": [
"extension.neon"
]
}
},
"scripts": {
"test": "@php vendor/bin/phpunit",
"phpstan": "@php phpstan analyse"
}
}

View File

@ -1,46 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllResult
{
/**
* An array of match group => list of matched strings
*
* @readonly
* @var array<int|string, list<string|null>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<int|string, list<string|null>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@ -1,46 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllStrictGroupsResult
{
/**
* An array of match group => list of matched strings
*
* @readonly
* @var array<int|string, list<string>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<list<string>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@ -1,48 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchAllWithOffsetsResult
{
/**
* An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, list<array{string|null, int}>>
* @phpstan-var array<int|string, list<array{string|null, int<-1, max>}>>
*/
public $matches;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<int|string, list<array{string|null, int}>> $matches
* @phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchResult
{
/**
* An array of match group => string matched
*
* @readonly
* @var array<int|string, string|null>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<string|null> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@ -1,39 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchStrictGroupsResult
{
/**
* An array of match group => string matched
*
* @readonly
* @var array<int|string, string>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<string> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@ -1,41 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class MatchWithOffsetsResult
{
/**
* An array of match group => pair of string matched + offset in bytes (or -1 if no match)
*
* @readonly
* @var array<int|string, array{string|null, int}>
* @phpstan-var array<int|string, array{string|null, int<-1, max>}>
*/
public $matches;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
* @param array<array{string|null, int}> $matches
* @phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
*/
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
}

View File

@ -1,60 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class PcreException extends \RuntimeException
{
/**
* @param string $function
* @param string|string[] $pattern
* @return self
*/
public static function fromFunction($function, $pattern)
{
$code = preg_last_error();
if (is_array($pattern)) {
$pattern = implode(', ', $pattern);
}
return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
}
/**
* @param int $code
* @return string
*/
private static function pcreLastErrorMessage($code)
{
if (function_exists('preg_last_error_msg')) {
return preg_last_error_msg();
}
// older php versions did not set the code properly in all cases
if (PHP_VERSION_ID < 70201 && $code === 0) {
return 'UNDEFINED_ERROR';
}
$constants = get_defined_constants(true);
if (!isset($constants['pcre'])) {
return 'UNDEFINED_ERROR';
}
foreach ($constants['pcre'] as $const => $val) {
if ($val === $code && substr($const, -6) === '_ERROR') {
return $const;
}
}
return 'UNDEFINED_ERROR';
}
}

View File

@ -1,430 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class Preg
{
/** @internal */
public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
/** @internal */
public const INVALID_TYPE_MSG = '$subject must be a string, %s given.';
/**
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|1
*
* @param-out array<int|string, string|null> $matches
*/
public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
if ($result === false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* Variant of `match()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|1
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, string> $matches
*/
public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
$result = self::match($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match');
return $result;
}
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported
* @return 0|1
*
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
{
$result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
if ($result === false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
/**
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|positive-int
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* Variant of `match()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @return 0|positive-int
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, list<string>> $matches
*/
public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
{
$result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll');
return $result;
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
* @return 0|positive-int
*
* @param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
{
self::checkSetOrder($flags);
$result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
* @param int $count Set by method
*
* @param-out int<0, max> $count
*/
public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace($pattern, $replacement, $subject, $limit, $count);
if ($result === null) {
throw PcreException::fromFunction('preg_replace', $pattern);
}
return $result;
}
/**
* @param string|string[] $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL);
if ($result === null) {
throw PcreException::fromFunction('preg_replace_callback', $pattern);
}
return $result;
}
/**
* Variant of `replaceCallback()` which outputs non-null matches (or throws)
*
* @param string $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
return self::replaceCallback($pattern, function (array $matches) use ($pattern, $replacement) {
return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback'));
}, $subject, $limit, $count, $flags);
}
/**
* @param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
* @param string $subject
* @param int $count Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*
* @param-out int<0, max> $count
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
{
if (!is_scalar($subject)) {
if (is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
}
$result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL);
if ($result === null) {
$pattern = array_keys($pattern);
throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
}
return $result;
}
/**
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
* @return list<string>
*/
public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
{
if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
}
$result = preg_split($pattern, $subject, $limit, $flags);
if ($result === false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
/**
* @param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set
* @return list<array{string, int}>
* @phpstan-return list<array{string, int<0, max>}>
*/
public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
{
$result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
if ($result === false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
/**
* @template T of string|\Stringable
* @param string $pattern
* @param array<T> $array
* @param int-mask<PREG_GREP_INVERT> $flags PREG_GREP_INVERT
* @return array<T>
*/
public static function grep(string $pattern, array $array, int $flags = 0): array
{
$result = preg_grep($pattern, $array, $flags);
if ($result === false) {
throw PcreException::fromFunction('preg_grep', $pattern);
}
return $result;
}
/**
* Variant of match() which returns a bool instead of int
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, string|null> $matches
*/
public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of `isMatch()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*
* @param-out array<int|string, string> $matches
*/
public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchAll() which returns a bool instead of int
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<string|null>> $matches
*/
public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of `isMatchAll()` which outputs non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<string>> $matches
*/
public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
{
return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchWithOffsets() which returns a bool instead of int
*
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, array{string|null, int<-1, max>}> $matches
*/
public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
/**
* Variant of matchAllWithOffsets() which returns a bool instead of int
*
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param array<mixed> $matches Set by method
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*
* @param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
*/
public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
{
return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
private static function checkOffsetCapture(int $flags, string $useFunctionName): void
{
if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead');
}
}
private static function checkSetOrder(int $flags): void
{
if (($flags & PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
}
}
/**
* @param array<int|string, string|null|array{string|null, int}> $matches
* @return array<int|string, string>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $match) {
if (is_string($match) || (is_array($match) && is_string($match[0]))) {
continue;
}
throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
}
/** @var array<string> */
return $matches;
}
/**
* @param array<int|string, list<string|null>> $matches
* @return array<int|string, list<string>>
* @throws UnexpectedNullMatchException
*/
private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $groupMatches) {
foreach ($groupMatches as $match) {
if (null === $match) {
throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
}
}
}
/** @var array<int|string, list<string>> */
return $matches;
}
}

View File

@ -1,176 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class Regex
{
/**
* @param non-empty-string $pattern
*/
public static function isMatch(string $pattern, string $subject, int $offset = 0): bool
{
return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
}
/**
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$count = Preg::match($pattern, $subject, $matches, $flags, $offset);
return new MatchResult($count, $matches);
}
/**
* Variant of `match()` which returns non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*/
public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult
{
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchStrictGroupsResult($count, $matches);
}
/**
* Runs preg_match with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult
{
$count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchWithOffsetsResult($count, $matches);
}
/**
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
*/
public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
return new MatchAllResult($count, $matches);
}
/**
* Variant of `matchAll()` which returns non-null matches (or throws)
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
* @throws UnexpectedNullMatchException
*/
public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchAllStrictGroupsResult($count, $matches);
}
/**
* Runs preg_match_all with PREG_OFFSET_CAPTURE
*
* @param non-empty-string $pattern
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
*/
public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult
{
self::checkSetOrder($flags);
$count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchAllWithOffsetsResult($count, $matches);
}
/**
* @param string|string[] $pattern
* @param string|string[] $replacement
* @param string $subject
*/
public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult
{
$result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
return new ReplaceResult($count, $result);
}
/**
* @param string|string[] $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
/**
* Variant of `replaceCallback()` which outputs non-null matches (or throws)
*
* @param string $pattern
* @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallbackStrictGroups($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallbackStrictGroups($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
/**
* @param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
* @param string $subject
* @param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
*/
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult
{
$result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
private static function checkOffsetCapture(int $flags, string $useFunctionName): void
{
if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
}
}
private static function checkSetOrder(int $flags): void
{
if (($flags & PREG_SET_ORDER) !== 0) {
throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
}
}
}

View File

@ -1,43 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
final class ReplaceResult
{
/**
* @readonly
* @var string
*/
public $result;
/**
* @readonly
* @var 0|positive-int
*/
public $count;
/**
* @readonly
* @var bool
*/
public $matched;
/**
* @param 0|positive-int $count
*/
public function __construct(int $count, string $result)
{
$this->count = $count;
$this->matched = (bool) $count;
$this->result = $result;
}
}

View File

@ -1,20 +0,0 @@
<?php
/*
* This file is part of composer/pcre.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Pcre;
class UnexpectedNullMatchException extends PcreException
{
public static function fromFunction($function, $pattern)
{
throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
}
}

View File

@ -1,30 +0,0 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}
if (PHP_INT_SIZE !== 8) {
$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}

View File

@ -1,224 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### [3.4.2] 2024-07-12
* Fixed PHP 5.3 syntax error
### [3.4.1] 2024-07-12
* Fixed normalizeStability's return type to enforce valid stabilities
### [3.4.0] 2023-08-31
* Support larger major version numbers (#149)
### [3.3.2] 2022-04-01
* Fixed handling of non-string values (#134)
### [3.3.1] 2022-03-16
* Fixed possible cache key clash in the CompilingMatcher memoization (#132)
### [3.3.0] 2022-03-15
* Improved performance of CompilingMatcher by memoizing more (#131)
* Added CompilingMatcher::clear to clear all memoization caches
### [3.2.9] 2022-02-04
* Revert #129 (Fixed MultiConstraint with MatchAllConstraint) which caused regressions
### [3.2.8] 2022-02-04
* Updates to latest phpstan / CI by @Seldaek in https://github.com/composer/semver/pull/130
* Fixed MultiConstraint with MatchAllConstraint by @Toflar in https://github.com/composer/semver/pull/129
### [3.2.7] 2022-01-04
* Fixed: typo in type definition of Intervals class causing issues with Psalm scanning vendors
### [3.2.6] 2021-10-25
* Fixed: type improvements to parseStability
### [3.2.5] 2021-05-24
* Fixed: issue comparing disjunctive MultiConstraints to conjunctive ones (#127)
* Fixed: added complete type information using phpstan annotations
### [3.2.4] 2020-11-13
* Fixed: code clean-up
### [3.2.3] 2020-11-12
* Fixed: constraints in the form of `X || Y, >=Y.1` and other such complex constructs were in some cases being optimized into a more restrictive constraint
### [3.2.2] 2020-10-14
* Fixed: internal code cleanups
### [3.2.1] 2020-09-27
* Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases
* Fixed: normalization of beta0 and such which was dropping the 0
### [3.2.0] 2020-09-09
* Added: support for `x || @dev`, not very useful but seen in the wild and failed to validate with 1.5.2/1.6.0
* Added: support for `foobar-dev` being equal to `dev-foobar`, dev-foobar is the official way to write it but we need to support the other for BC and convenience
### [3.1.0] 2020-09-08
* Added: support for constraints like `^2.x-dev` and `~2.x-dev`, not very useful but seen in the wild and failed to validate with 3.0.1
* Fixed: invalid aliases will no longer throw, unless explicitly validated by Composer in the root package
### [3.0.1] 2020-09-08
* Fixed: handling of some invalid -dev versions which were seen as valid
### [3.0.0] 2020-05-26
* Break: Renamed `EmptyConstraint`, replace it with `MatchAllConstraint`
* Break: Unlikely to affect anyone but strictly speaking a breaking change, `*.*` and such variants will not match all `dev-*` versions anymore, only `*` does
* Break: ConstraintInterface is now considered internal/private and not meant to be implemented by third parties anymore
* Added `Intervals` class to check if a constraint is a subsets of another one, and allow compacting complex MultiConstraints into simpler ones
* Added `CompilingMatcher` class to speed up constraint matching against simple Constraint instances
* Added `MatchAllConstraint` and `MatchNoneConstraint` which match everything and nothing
* Added more advanced optimization of contiguous constraints inside MultiConstraint
* Added tentative support for PHP 8
* Fixed ConstraintInterface::matches to be commutative in all cases
### [2.0.0] 2020-04-21
* Break: `dev-master`, `dev-trunk` and `dev-default` now normalize to `dev-master`, `dev-trunk` and `dev-default` instead of `9999999-dev` in 1.x
* Break: Removed the deprecated `AbstractConstraint`
* Added `getUpperBound` and `getLowerBound` to ConstraintInterface. They return `Composer\Semver\Constraint\Bound` instances
* Added `MultiConstraint::create` to create the most-optimal form of ConstraintInterface from an array of constraint strings
### [1.7.2] 2020-12-03
* Fixed: Allow installing on php 8
### [1.7.1] 2020-09-27
* Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases
* Fixed: normalization of beta0 and such which was dropping the 0
### [1.7.0] 2020-09-09
* Added: support for `x || @dev`, not very useful but seen in the wild and failed to validate with 1.5.2/1.6.0
* Added: support for `foobar-dev` being equal to `dev-foobar`, dev-foobar is the official way to write it but we need to support the other for BC and convenience
### [1.6.0] 2020-09-08
* Added: support for constraints like `^2.x-dev` and `~2.x-dev`, not very useful but seen in the wild and failed to validate with 1.5.2
* Fixed: invalid aliases will no longer throw, unless explicitly validated by Composer in the root package
### [1.5.2] 2020-09-08
* Fixed: handling of some invalid -dev versions which were seen as valid
* Fixed: some doctypes
### [1.5.1] 2020-01-13
* Fixed: Parsing of aliased version was not validating the alias to be a valid version
### [1.5.0] 2019-03-19
* Added: some support for date versions (e.g. 201903) in `~` operator
* Fixed: support for stabilities in `~` operator was inconsistent
### [1.4.2] 2016-08-30
* Fixed: collapsing of complex constraints lead to buggy constraints
### [1.4.1] 2016-06-02
* Changed: branch-like requirements no longer strip build metadata - [composer/semver#38](https://github.com/composer/semver/pull/38).
### [1.4.0] 2016-03-30
* Added: getters on MultiConstraint - [composer/semver#35](https://github.com/composer/semver/pull/35).
### [1.3.0] 2016-02-25
* Fixed: stability parsing - [composer/composer#1234](https://github.com/composer/composer/issues/4889).
* Changed: collapse contiguous constraints when possible.
### [1.2.0] 2015-11-10
* Changed: allow multiple numerical identifiers in 'pre-release' version part.
* Changed: add more 'v' prefix support.
### [1.1.0] 2015-11-03
* Changed: dropped redundant `test` namespace.
* Changed: minor adjustment in datetime parsing normalization.
* Changed: `ConstraintInterface` relaxed, setPrettyString is not required anymore.
* Changed: `AbstractConstraint` marked deprecated, will be removed in 2.0.
* Changed: `Constraint` is now extensible.
### [1.0.0] 2015-09-21
* Break: `VersionConstraint` renamed to `Constraint`.
* Break: `SpecificConstraint` renamed to `AbstractConstraint`.
* Break: `LinkConstraintInterface` renamed to `ConstraintInterface`.
* Break: `VersionParser::parseNameVersionPairs` was removed.
* Changed: `VersionParser::parseConstraints` allows (but ignores) build metadata now.
* Changed: `VersionParser::parseConstraints` allows (but ignores) prefixing numeric versions with a 'v' now.
* Changed: Fixed namespace(s) of test files.
* Changed: `Comparator::compare` no longer throws `InvalidArgumentException`.
* Changed: `Constraint` now throws `InvalidArgumentException`.
### [0.1.0] 2015-07-23
* Added: `Composer\Semver\Comparator`, various methods to compare versions.
* Added: various documents such as README.md, LICENSE, etc.
* Added: configuration files for Git, Travis, php-cs-fixer, phpunit.
* Break: the following namespaces were renamed:
- Namespace: `Composer\Package\Version` -> `Composer\Semver`
- Namespace: `Composer\Package\LinkConstraint` -> `Composer\Semver\Constraint`
- Namespace: `Composer\Test\Package\Version` -> `Composer\Test\Semver`
- Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint`
* Changed: code style using php-cs-fixer.
[3.4.2]: https://github.com/composer/semver/compare/3.4.1...3.4.2
[3.4.1]: https://github.com/composer/semver/compare/3.4.0...3.4.1
[3.4.0]: https://github.com/composer/semver/compare/3.3.2...3.4.0
[3.3.2]: https://github.com/composer/semver/compare/3.3.1...3.3.2
[3.3.1]: https://github.com/composer/semver/compare/3.3.0...3.3.1
[3.3.0]: https://github.com/composer/semver/compare/3.2.9...3.3.0
[3.2.9]: https://github.com/composer/semver/compare/3.2.8...3.2.9
[3.2.8]: https://github.com/composer/semver/compare/3.2.7...3.2.8
[3.2.7]: https://github.com/composer/semver/compare/3.2.6...3.2.7
[3.2.6]: https://github.com/composer/semver/compare/3.2.5...3.2.6
[3.2.5]: https://github.com/composer/semver/compare/3.2.4...3.2.5
[3.2.4]: https://github.com/composer/semver/compare/3.2.3...3.2.4
[3.2.3]: https://github.com/composer/semver/compare/3.2.2...3.2.3
[3.2.2]: https://github.com/composer/semver/compare/3.2.1...3.2.2
[3.2.1]: https://github.com/composer/semver/compare/3.2.0...3.2.1
[3.2.0]: https://github.com/composer/semver/compare/3.1.0...3.2.0
[3.1.0]: https://github.com/composer/semver/compare/3.0.1...3.1.0
[3.0.1]: https://github.com/composer/semver/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/composer/semver/compare/2.0.0...3.0.0
[2.0.0]: https://github.com/composer/semver/compare/1.5.1...2.0.0
[1.7.2]: https://github.com/composer/semver/compare/1.7.1...1.7.2
[1.7.1]: https://github.com/composer/semver/compare/1.7.0...1.7.1
[1.7.0]: https://github.com/composer/semver/compare/1.6.0...1.7.0
[1.6.0]: https://github.com/composer/semver/compare/1.5.2...1.6.0
[1.5.2]: https://github.com/composer/semver/compare/1.5.1...1.5.2
[1.5.1]: https://github.com/composer/semver/compare/1.5.0...1.5.1
[1.5.0]: https://github.com/composer/semver/compare/1.4.2...1.5.0
[1.4.2]: https://github.com/composer/semver/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/composer/semver/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/composer/semver/compare/1.3.0...1.4.0
[1.3.0]: https://github.com/composer/semver/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/composer/semver/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/composer/semver/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/composer/semver/compare/0.1.0...1.0.0
[0.1.0]: https://github.com/composer/semver/compare/5e0b9a4da...0.1.0

View File

@ -1,19 +0,0 @@
Copyright (C) 2015 Composer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,99 +0,0 @@
composer/semver
===============
Semver (Semantic Versioning) library that offers utilities, version constraint parsing and validation.
Originally written as part of [composer/composer](https://github.com/composer/composer),
now extracted and made available as a stand-alone library.
[![Continuous Integration](https://github.com/composer/semver/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/continuous-integration.yml)
[![PHP Lint](https://github.com/composer/semver/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/lint.yml)
[![PHPStan](https://github.com/composer/semver/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/phpstan.yml)
Installation
------------
Install the latest version with:
```bash
composer require composer/semver
```
Requirements
------------
* PHP 5.3.2 is required but using the latest version of PHP is highly recommended.
Version Comparison
------------------
For details on how versions are compared, refer to the [Versions](https://getcomposer.org/doc/articles/versions.md)
article in the documentation section of the [getcomposer.org](https://getcomposer.org) website.
Basic usage
-----------
### Comparator
The [`Composer\Semver\Comparator`](https://github.com/composer/semver/blob/main/src/Comparator.php) class provides the following methods for comparing versions:
* greaterThan($v1, $v2)
* greaterThanOrEqualTo($v1, $v2)
* lessThan($v1, $v2)
* lessThanOrEqualTo($v1, $v2)
* equalTo($v1, $v2)
* notEqualTo($v1, $v2)
Each function takes two version strings as arguments and returns a boolean. For example:
```php
use Composer\Semver\Comparator;
Comparator::greaterThan('1.25.0', '1.24.0'); // 1.25.0 > 1.24.0
```
### Semver
The [`Composer\Semver\Semver`](https://github.com/composer/semver/blob/main/src/Semver.php) class provides the following methods:
* satisfies($version, $constraints)
* satisfiedBy(array $versions, $constraint)
* sort($versions)
* rsort($versions)
### Intervals
The [`Composer\Semver\Intervals`](https://github.com/composer/semver/blob/main/src/Intervals.php) static class provides
a few utilities to work with complex constraints or read version intervals from a constraint:
```php
use Composer\Semver\Intervals;
// Checks whether $candidate is a subset of $constraint
Intervals::isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint);
// Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
Intervals::haveIntersections(ConstraintInterface $a, ConstraintInterface $b);
// Optimizes a complex multi constraint by merging all intervals down to the smallest
// possible multi constraint. The drawbacks are this is not very fast, and the resulting
// multi constraint will have no human readable prettyConstraint configured on it
Intervals::compactConstraint(ConstraintInterface $constraint);
// Creates an array of numeric intervals and branch constraints representing a given constraint
Intervals::get(ConstraintInterface $constraint);
// Clears the memoization cache when you are done processing constraints
Intervals::clear()
```
See the class docblocks for more details.
License
-------
composer/semver is licensed under the MIT License, see the LICENSE file for details.

View File

@ -1,59 +0,0 @@
{
"name": "composer/semver",
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"type": "library",
"license": "MIT",
"keywords": [
"semver",
"semantic",
"versioning",
"validation"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues"
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.2 || ^5",
"phpstan/phpstan": "^1.4"
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\Semver\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"scripts": {
"test": "SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 vendor/bin/simple-phpunit",
"phpstan": "@php vendor/bin/phpstan analyse"
}
}

View File

@ -1,113 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\Constraint;
class Comparator
{
/**
* Evaluates the expression: $version1 > $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function greaterThan($version1, $version2)
{
return self::compare($version1, '>', $version2);
}
/**
* Evaluates the expression: $version1 >= $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function greaterThanOrEqualTo($version1, $version2)
{
return self::compare($version1, '>=', $version2);
}
/**
* Evaluates the expression: $version1 < $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function lessThan($version1, $version2)
{
return self::compare($version1, '<', $version2);
}
/**
* Evaluates the expression: $version1 <= $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function lessThanOrEqualTo($version1, $version2)
{
return self::compare($version1, '<=', $version2);
}
/**
* Evaluates the expression: $version1 == $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function equalTo($version1, $version2)
{
return self::compare($version1, '==', $version2);
}
/**
* Evaluates the expression: $version1 != $version2.
*
* @param string $version1
* @param string $version2
*
* @return bool
*/
public static function notEqualTo($version1, $version2)
{
return self::compare($version1, '!=', $version2);
}
/**
* Evaluates the expression: $version1 $operator $version2.
*
* @param string $version1
* @param string $operator
* @param string $version2
*
* @return bool
*
* @phpstan-param Constraint::STR_OP_* $operator
*/
public static function compare($version1, $operator, $version2)
{
$constraint = new Constraint($operator, $version2);
return $constraint->matchSpecific(new Constraint('==', $version1), true);
}
}

View File

@ -1,94 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\ConstraintInterface;
/**
* Helper class to evaluate constraint by compiling and reusing the code to evaluate
*/
class CompilingMatcher
{
/**
* @var array
* @phpstan-var array<string, callable>
*/
private static $compiledCheckerCache = array();
/**
* @var array
* @phpstan-var array<string, bool>
*/
private static $resultCache = array();
/** @var bool */
private static $enabled;
/**
* @phpstan-var array<Constraint::OP_*, Constraint::STR_OP_*>
*/
private static $transOpInt = array(
Constraint::OP_EQ => Constraint::STR_OP_EQ,
Constraint::OP_LT => Constraint::STR_OP_LT,
Constraint::OP_LE => Constraint::STR_OP_LE,
Constraint::OP_GT => Constraint::STR_OP_GT,
Constraint::OP_GE => Constraint::STR_OP_GE,
Constraint::OP_NE => Constraint::STR_OP_NE,
);
/**
* Clears the memoization cache once you are done
*
* @return void
*/
public static function clear()
{
self::$resultCache = array();
self::$compiledCheckerCache = array();
}
/**
* Evaluates the expression: $constraint match $operator $version
*
* @param ConstraintInterface $constraint
* @param int $operator
* @phpstan-param Constraint::OP_* $operator
* @param string $version
*
* @return mixed
*/
public static function match(ConstraintInterface $constraint, $operator, $version)
{
$resultCacheKey = $operator.$constraint.';'.$version;
if (isset(self::$resultCache[$resultCacheKey])) {
return self::$resultCache[$resultCacheKey];
}
if (self::$enabled === null) {
self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
}
if (!self::$enabled) {
return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
}
$cacheKey = $operator.$constraint;
if (!isset(self::$compiledCheckerCache[$cacheKey])) {
$code = $constraint->compile($operator);
self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
} else {
$function = self::$compiledCheckerCache[$cacheKey];
}
return self::$resultCache[$resultCacheKey] = $function($version, strpos($version, 'dev-') === 0);
}
}

View File

@ -1,122 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
class Bound
{
/**
* @var string
*/
private $version;
/**
* @var bool
*/
private $isInclusive;
/**
* @param string $version
* @param bool $isInclusive
*/
public function __construct($version, $isInclusive)
{
$this->version = $version;
$this->isInclusive = $isInclusive;
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @return bool
*/
public function isInclusive()
{
return $this->isInclusive;
}
/**
* @return bool
*/
public function isZero()
{
return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
}
/**
* @return bool
*/
public function isPositiveInfinity()
{
return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
}
/**
* Compares a bound to another with a given operator.
*
* @param Bound $other
* @param string $operator
*
* @return bool
*/
public function compareTo(Bound $other, $operator)
{
if (!\in_array($operator, array('<', '>'), true)) {
throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
}
// If they are the same it doesn't matter
if ($this == $other) {
return false;
}
$compareResult = version_compare($this->getVersion(), $other->getVersion());
// Not the same version means we don't need to check if the bounds are inclusive or not
if (0 !== $compareResult) {
return (('>' === $operator) ? 1 : -1) === $compareResult;
}
// Question we're answering here is "am I higher than $other?"
return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
}
public function __toString()
{
return sprintf(
'%s [%s]',
$this->getVersion(),
$this->isInclusive() ? 'inclusive' : 'exclusive'
);
}
/**
* @return self
*/
public static function zero()
{
return new Bound('0.0.0.0-dev', true);
}
/**
* @return self
*/
public static function positiveInfinity()
{
return new Bound(PHP_INT_MAX.'.0.0.0', false);
}
}

View File

@ -1,435 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
/**
* Defines a constraint.
*/
class Constraint implements ConstraintInterface
{
/* operator integer values */
const OP_EQ = 0;
const OP_LT = 1;
const OP_LE = 2;
const OP_GT = 3;
const OP_GE = 4;
const OP_NE = 5;
/* operator string values */
const STR_OP_EQ = '==';
const STR_OP_EQ_ALT = '=';
const STR_OP_LT = '<';
const STR_OP_LE = '<=';
const STR_OP_GT = '>';
const STR_OP_GE = '>=';
const STR_OP_NE = '!=';
const STR_OP_NE_ALT = '<>';
/**
* Operator to integer translation table.
*
* @var array
* @phpstan-var array<self::STR_OP_*, self::OP_*>
*/
private static $transOpStr = array(
'=' => self::OP_EQ,
'==' => self::OP_EQ,
'<' => self::OP_LT,
'<=' => self::OP_LE,
'>' => self::OP_GT,
'>=' => self::OP_GE,
'<>' => self::OP_NE,
'!=' => self::OP_NE,
);
/**
* Integer to operator translation table.
*
* @var array
* @phpstan-var array<self::OP_*, self::STR_OP_*>
*/
private static $transOpInt = array(
self::OP_EQ => '==',
self::OP_LT => '<',
self::OP_LE => '<=',
self::OP_GT => '>',
self::OP_GE => '>=',
self::OP_NE => '!=',
);
/**
* @var int
* @phpstan-var self::OP_*
*/
protected $operator;
/** @var string */
protected $version;
/** @var string|null */
protected $prettyString;
/** @var Bound */
protected $lowerBound;
/** @var Bound */
protected $upperBound;
/**
* Sets operator and version to compare with.
*
* @param string $operator
* @param string $version
*
* @throws \InvalidArgumentException if invalid operator is given.
*
* @phpstan-param self::STR_OP_* $operator
*/
public function __construct($operator, $version)
{
if (!isset(self::$transOpStr[$operator])) {
throw new \InvalidArgumentException(sprintf(
'Invalid operator "%s" given, expected one of: %s',
$operator,
implode(', ', self::getSupportedOperators())
));
}
$this->operator = self::$transOpStr[$operator];
$this->version = $version;
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @return string
*
* @phpstan-return self::STR_OP_*
*/
public function getOperator()
{
return self::$transOpInt[$this->operator];
}
/**
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider)
{
if ($provider instanceof self) {
return $this->matchSpecific($provider);
}
// turn matching around to find a match
return $provider->matches($this);
}
/**
* {@inheritDoc}
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}
/**
* {@inheritDoc}
*/
public function getPrettyString()
{
if ($this->prettyString) {
return $this->prettyString;
}
return $this->__toString();
}
/**
* Get all supported comparison operators.
*
* @return array
*
* @phpstan-return list<self::STR_OP_*>
*/
public static function getSupportedOperators()
{
return array_keys(self::$transOpStr);
}
/**
* @param string $operator
* @return int
*
* @phpstan-param self::STR_OP_* $operator
* @phpstan-return self::OP_*
*/
public static function getOperatorConstant($operator)
{
return self::$transOpStr[$operator];
}
/**
* @param string $a
* @param string $b
* @param string $operator
* @param bool $compareBranches
*
* @throws \InvalidArgumentException if invalid operator is given.
*
* @return bool
*
* @phpstan-param self::STR_OP_* $operator
*/
public function versionCompare($a, $b, $operator, $compareBranches = false)
{
if (!isset(self::$transOpStr[$operator])) {
throw new \InvalidArgumentException(sprintf(
'Invalid operator "%s" given, expected one of: %s',
$operator,
implode(', ', self::getSupportedOperators())
));
}
$aIsBranch = strpos($a, 'dev-') === 0;
$bIsBranch = strpos($b, 'dev-') === 0;
if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
return $a !== $b;
}
if ($aIsBranch && $bIsBranch) {
return $operator === '==' && $a === $b;
}
// when branches are not comparable, we make sure dev branches never match anything
if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
return false;
}
return \version_compare($a, $b, $operator);
}
/**
* {@inheritDoc}
*/
public function compile($otherOperator)
{
if (strpos($this->version, 'dev-') === 0) {
if (self::OP_EQ === $this->operator) {
if (self::OP_EQ === $otherOperator) {
return sprintf('$b && $v === %s', \var_export($this->version, true));
}
if (self::OP_NE === $otherOperator) {
return sprintf('!$b || $v !== %s', \var_export($this->version, true));
}
return 'false';
}
if (self::OP_NE === $this->operator) {
if (self::OP_EQ === $otherOperator) {
return sprintf('!$b || $v !== %s', \var_export($this->version, true));
}
if (self::OP_NE === $otherOperator) {
return 'true';
}
return '!$b';
}
return 'false';
}
if (self::OP_EQ === $this->operator) {
if (self::OP_EQ === $otherOperator) {
return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
}
if (self::OP_NE === $otherOperator) {
return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
}
return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
}
if (self::OP_NE === $this->operator) {
if (self::OP_EQ === $otherOperator) {
return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
}
if (self::OP_NE === $otherOperator) {
return 'true';
}
return '!$b';
}
if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
return '!$b';
}
} else { // $this->operator must be self::OP_GT || self::OP_GE here
if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
return '!$b';
}
}
if (self::OP_NE === $otherOperator) {
return 'true';
}
$codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
if ($this->operator === self::OP_LE) {
if ($otherOperator === self::OP_GT) {
return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
}
} elseif ($this->operator === self::OP_GE) {
if ($otherOperator === self::OP_LT) {
return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
}
}
return sprintf('!$b && %s', $codeComparison);
}
/**
* @param Constraint $provider
* @param bool $compareBranches
*
* @return bool
*/
public function matchSpecific(Constraint $provider, $compareBranches = false)
{
$noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
$providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
$isEqualOp = self::OP_EQ === $this->operator;
$isNonEqualOp = self::OP_NE === $this->operator;
$isProviderEqualOp = self::OP_EQ === $provider->operator;
$isProviderNonEqualOp = self::OP_NE === $provider->operator;
// '!=' operator is match when other operator is not '==' operator or version is not match
// these kinds of comparisons always have a solution
if ($isNonEqualOp || $isProviderNonEqualOp) {
if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
return false;
}
if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
return false;
}
if (!$isEqualOp && !$isProviderEqualOp) {
return true;
}
return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
}
// an example for the condition is <= 2.0 & < 1.0
// these kinds of comparisons always have a solution
if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
}
$version1 = $isEqualOp ? $this->version : $provider->version;
$version2 = $isEqualOp ? $provider->version : $this->version;
$operator = $isEqualOp ? $provider->operator : $this->operator;
if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
// special case, e.g. require >= 1.0 and provide < 1.0
// 1.0 >= 1.0 but 1.0 is outside of the provided interval
return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
&& self::$transOpInt[$this->operator] !== $noEqualOp
&& \version_compare($provider->version, $this->version, '=='));
}
return false;
}
/**
* @return string
*/
public function __toString()
{
return self::$transOpInt[$this->operator] . ' ' . $this->version;
}
/**
* {@inheritDoc}
*/
public function getLowerBound()
{
$this->extractBounds();
return $this->lowerBound;
}
/**
* {@inheritDoc}
*/
public function getUpperBound()
{
$this->extractBounds();
return $this->upperBound;
}
/**
* @return void
*/
private function extractBounds()
{
if (null !== $this->lowerBound) {
return;
}
// Branches
if (strpos($this->version, 'dev-') === 0) {
$this->lowerBound = Bound::zero();
$this->upperBound = Bound::positiveInfinity();
return;
}
switch ($this->operator) {
case self::OP_EQ:
$this->lowerBound = new Bound($this->version, true);
$this->upperBound = new Bound($this->version, true);
break;
case self::OP_LT:
$this->lowerBound = Bound::zero();
$this->upperBound = new Bound($this->version, false);
break;
case self::OP_LE:
$this->lowerBound = Bound::zero();
$this->upperBound = new Bound($this->version, true);
break;
case self::OP_GT:
$this->lowerBound = new Bound($this->version, false);
$this->upperBound = Bound::positiveInfinity();
break;
case self::OP_GE:
$this->lowerBound = new Bound($this->version, true);
$this->upperBound = Bound::positiveInfinity();
break;
case self::OP_NE:
$this->lowerBound = Bound::zero();
$this->upperBound = Bound::positiveInfinity();
break;
}
}
}

View File

@ -1,75 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
/**
* DO NOT IMPLEMENT this interface. It is only meant for usage as a type hint
* in libraries relying on composer/semver but creating your own constraint class
* that implements this interface is not a supported use case and will cause the
* composer/semver components to return unexpected results.
*/
interface ConstraintInterface
{
/**
* Checks whether the given constraint intersects in any way with this constraint
*
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider);
/**
* Provides a compiled version of the constraint for the given operator
* The compiled version must be a PHP expression.
* Executor of compile version must provide 2 variables:
* - $v = the string version to compare with
* - $b = whether or not the version is a non-comparable branch (starts with "dev-")
*
* @see Constraint::OP_* for the list of available operators.
* @example return '!$b && version_compare($v, '1.0', '>')';
*
* @param int $otherOperator one Constraint::OP_*
*
* @return string
*
* @phpstan-param Constraint::OP_* $otherOperator
*/
public function compile($otherOperator);
/**
* @return Bound
*/
public function getUpperBound();
/**
* @return Bound
*/
public function getLowerBound();
/**
* @return string
*/
public function getPrettyString();
/**
* @param string|null $prettyString
*
* @return void
*/
public function setPrettyString($prettyString);
/**
* @return string
*/
public function __toString();
}

View File

@ -1,85 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
/**
* Defines the absence of a constraint.
*
* This constraint matches everything.
*/
class MatchAllConstraint implements ConstraintInterface
{
/** @var string|null */
protected $prettyString;
/**
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider)
{
return true;
}
/**
* {@inheritDoc}
*/
public function compile($otherOperator)
{
return 'true';
}
/**
* {@inheritDoc}
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}
/**
* {@inheritDoc}
*/
public function getPrettyString()
{
if ($this->prettyString) {
return $this->prettyString;
}
return (string) $this;
}
/**
* {@inheritDoc}
*/
public function __toString()
{
return '*';
}
/**
* {@inheritDoc}
*/
public function getUpperBound()
{
return Bound::positiveInfinity();
}
/**
* {@inheritDoc}
*/
public function getLowerBound()
{
return Bound::zero();
}
}

View File

@ -1,83 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
/**
* Blackhole of constraints, nothing escapes it
*/
class MatchNoneConstraint implements ConstraintInterface
{
/** @var string|null */
protected $prettyString;
/**
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider)
{
return false;
}
/**
* {@inheritDoc}
*/
public function compile($otherOperator)
{
return 'false';
}
/**
* {@inheritDoc}
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}
/**
* {@inheritDoc}
*/
public function getPrettyString()
{
if ($this->prettyString) {
return $this->prettyString;
}
return (string) $this;
}
/**
* {@inheritDoc}
*/
public function __toString()
{
return '[]';
}
/**
* {@inheritDoc}
*/
public function getUpperBound()
{
return new Bound('0.0.0.0-dev', false);
}
/**
* {@inheritDoc}
*/
public function getLowerBound()
{
return new Bound('0.0.0.0-dev', false);
}
}

View File

@ -1,325 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver\Constraint;
/**
* Defines a conjunctive or disjunctive set of constraints.
*/
class MultiConstraint implements ConstraintInterface
{
/**
* @var ConstraintInterface[]
* @phpstan-var non-empty-array<ConstraintInterface>
*/
protected $constraints;
/** @var string|null */
protected $prettyString;
/** @var string|null */
protected $string;
/** @var bool */
protected $conjunctive;
/** @var Bound|null */
protected $lowerBound;
/** @var Bound|null */
protected $upperBound;
/**
* @param ConstraintInterface[] $constraints A set of constraints
* @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
*
* @throws \InvalidArgumentException If less than 2 constraints are passed
*/
public function __construct(array $constraints, $conjunctive = true)
{
if (\count($constraints) < 2) {
throw new \InvalidArgumentException(
'Must provide at least two constraints for a MultiConstraint. Use '.
'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
'MultiConstraint::create() which optimizes and handles those cases automatically.'
);
}
$this->constraints = $constraints;
$this->conjunctive = $conjunctive;
}
/**
* @return ConstraintInterface[]
*/
public function getConstraints()
{
return $this->constraints;
}
/**
* @return bool
*/
public function isConjunctive()
{
return $this->conjunctive;
}
/**
* @return bool
*/
public function isDisjunctive()
{
return !$this->conjunctive;
}
/**
* {@inheritDoc}
*/
public function compile($otherOperator)
{
$parts = array();
foreach ($this->constraints as $constraint) {
$code = $constraint->compile($otherOperator);
if ($code === 'true') {
if (!$this->conjunctive) {
return 'true';
}
} elseif ($code === 'false') {
if ($this->conjunctive) {
return 'false';
}
} else {
$parts[] = '('.$code.')';
}
}
if (!$parts) {
return $this->conjunctive ? 'true' : 'false';
}
return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
}
/**
* @param ConstraintInterface $provider
*
* @return bool
*/
public function matches(ConstraintInterface $provider)
{
if (false === $this->conjunctive) {
foreach ($this->constraints as $constraint) {
if ($provider->matches($constraint)) {
return true;
}
}
return false;
}
// when matching a conjunctive and a disjunctive multi constraint we have to iterate over the disjunctive one
// otherwise we'd return true if different parts of the disjunctive constraint match the conjunctive one
// which would lead to incorrect results, e.g. [>1 and <2] would match [<1 or >2] although they do not intersect
if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
return $provider->matches($this);
}
foreach ($this->constraints as $constraint) {
if (!$provider->matches($constraint)) {
return false;
}
}
return true;
}
/**
* {@inheritDoc}
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}
/**
* {@inheritDoc}
*/
public function getPrettyString()
{
if ($this->prettyString) {
return $this->prettyString;
}
return (string) $this;
}
/**
* {@inheritDoc}
*/
public function __toString()
{
if ($this->string !== null) {
return $this->string;
}
$constraints = array();
foreach ($this->constraints as $constraint) {
$constraints[] = (string) $constraint;
}
return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
}
/**
* {@inheritDoc}
*/
public function getLowerBound()
{
$this->extractBounds();
if (null === $this->lowerBound) {
throw new \LogicException('extractBounds should have populated the lowerBound property');
}
return $this->lowerBound;
}
/**
* {@inheritDoc}
*/
public function getUpperBound()
{
$this->extractBounds();
if (null === $this->upperBound) {
throw new \LogicException('extractBounds should have populated the upperBound property');
}
return $this->upperBound;
}
/**
* Tries to optimize the constraints as much as possible, meaning
* reducing/collapsing congruent constraints etc.
* Does not necessarily return a MultiConstraint instance if
* things can be reduced to a simple constraint
*
* @param ConstraintInterface[] $constraints A set of constraints
* @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
*
* @return ConstraintInterface
*/
public static function create(array $constraints, $conjunctive = true)
{
if (0 === \count($constraints)) {
return new MatchAllConstraint();
}
if (1 === \count($constraints)) {
return $constraints[0];
}
$optimized = self::optimizeConstraints($constraints, $conjunctive);
if ($optimized !== null) {
list($constraints, $conjunctive) = $optimized;
if (\count($constraints) === 1) {
return $constraints[0];
}
}
return new self($constraints, $conjunctive);
}
/**
* @param ConstraintInterface[] $constraints
* @param bool $conjunctive
* @return ?array
*
* @phpstan-return array{0: list<ConstraintInterface>, 1: bool}|null
*/
private static function optimizeConstraints(array $constraints, $conjunctive)
{
// parse the two OR groups and if they are contiguous we collapse
// them into one constraint
// [>= 1 < 2] || [>= 2 < 3] || [>= 3 < 4] => [>= 1 < 4]
if (!$conjunctive) {
$left = $constraints[0];
$mergedConstraints = array();
$optimized = false;
for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
$right = $constraints[$i];
if (
$left instanceof self
&& $left->conjunctive
&& $right instanceof self
&& $right->conjunctive
&& \count($left->constraints) === 2
&& \count($right->constraints) === 2
&& ($left0 = (string) $left->constraints[0])
&& $left0[0] === '>' && $left0[1] === '='
&& ($left1 = (string) $left->constraints[1])
&& $left1[0] === '<'
&& ($right0 = (string) $right->constraints[0])
&& $right0[0] === '>' && $right0[1] === '='
&& ($right1 = (string) $right->constraints[1])
&& $right1[0] === '<'
&& substr($left1, 2) === substr($right0, 3)
) {
$optimized = true;
$left = new MultiConstraint(
array(
$left->constraints[0],
$right->constraints[1],
),
true);
} else {
$mergedConstraints[] = $left;
$left = $right;
}
}
if ($optimized) {
$mergedConstraints[] = $left;
return array($mergedConstraints, false);
}
}
// TODO: Here's the place to put more optimizations
return null;
}
/**
* @return void
*/
private function extractBounds()
{
if (null !== $this->lowerBound) {
return;
}
foreach ($this->constraints as $constraint) {
if (null === $this->lowerBound || null === $this->upperBound) {
$this->lowerBound = $constraint->getLowerBound();
$this->upperBound = $constraint->getUpperBound();
continue;
}
if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
$this->lowerBound = $constraint->getLowerBound();
}
if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
$this->upperBound = $constraint->getUpperBound();
}
}
}
}

View File

@ -1,98 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\Constraint;
class Interval
{
/** @var Constraint */
private $start;
/** @var Constraint */
private $end;
public function __construct(Constraint $start, Constraint $end)
{
$this->start = $start;
$this->end = $end;
}
/**
* @return Constraint
*/
public function getStart()
{
return $this->start;
}
/**
* @return Constraint
*/
public function getEnd()
{
return $this->end;
}
/**
* @return Constraint
*/
public static function fromZero()
{
static $zero;
if (null === $zero) {
$zero = new Constraint('>=', '0.0.0.0-dev');
}
return $zero;
}
/**
* @return Constraint
*/
public static function untilPositiveInfinity()
{
static $positiveInfinity;
if (null === $positiveInfinity) {
$positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
}
return $positiveInfinity;
}
/**
* @return self
*/
public static function any()
{
return new self(self::fromZero(), self::untilPositiveInfinity());
}
/**
* @return array{'names': string[], 'exclude': bool}
*/
public static function anyDev()
{
// any == exclude nothing
return array('names' => array(), 'exclude' => true);
}
/**
* @return array{'names': string[], 'exclude': bool}
*/
public static function noDev()
{
// nothing == no names included
return array('names' => array(), 'exclude' => false);
}
}

View File

@ -1,478 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Semver\Constraint\MatchNoneConstraint;
use Composer\Semver\Constraint\MultiConstraint;
/**
* Helper class generating intervals from constraints
*
* This contains utilities for:
*
* - compacting an existing constraint which can be used to combine several into one
* by creating a MultiConstraint out of the many constraints you have.
*
* - checking whether one subset is a subset of another.
*
* Note: You should call clear to free memoization memory usage when you are done using this class
*/
class Intervals
{
/**
* @phpstan-var array<string, array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}>
*/
private static $intervalsCache = array();
/**
* @phpstan-var array<string, int>
*/
private static $opSortOrder = array(
'>=' => -3,
'<' => -2,
'>' => 2,
'<=' => 3,
);
/**
* Clears the memoization cache once you are done
*
* @return void
*/
public static function clear()
{
self::$intervalsCache = array();
}
/**
* Checks whether $candidate is a subset of $constraint
*
* @return bool
*/
public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
{
if ($constraint instanceof MatchAllConstraint) {
return true;
}
if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
return false;
}
$intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
$candidateIntervals = self::get($candidate);
if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
return false;
}
foreach ($intersectionIntervals['numeric'] as $index => $interval) {
if (!isset($candidateIntervals['numeric'][$index])) {
return false;
}
if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
return false;
}
if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
return false;
}
}
if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
return false;
}
if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
return false;
}
foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
if ($name !== $candidateIntervals['branches']['names'][$index]) {
return false;
}
}
return true;
}
/**
* Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
*
* @return bool
*/
public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
{
if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
return true;
}
if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
return false;
}
$intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
}
/**
* Attempts to optimize a MultiConstraint
*
* When merging MultiConstraints together they can get very large, this will
* compact it by looking at the real intervals covered by all the constraints
* and then creates a new constraint containing only the smallest amount of rules
* to match the same intervals.
*
* @return ConstraintInterface
*/
public static function compactConstraint(ConstraintInterface $constraint)
{
if (!$constraint instanceof MultiConstraint) {
return $constraint;
}
$intervals = self::generateIntervals($constraint);
$constraints = array();
$hasNumericMatchAll = false;
if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
$constraints[] = $intervals['numeric'][0]->getStart();
$hasNumericMatchAll = true;
} else {
$unEqualConstraints = array();
for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
$interval = $intervals['numeric'][$i];
// if current interval ends with < N and next interval begins with > N we can swap this out for != N
// but this needs to happen as a conjunctive expression together with the start of the current interval
// and end of next interval, so [>=M, <N] || [>N, <P] => [>=M, !=N, <P] but M/P can be skipped if
// they are zero/+inf
if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
$nextInterval = $intervals['numeric'][$i+1];
if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
// only add a start if we didn't already do so, can be skipped if we're looking at second
// interval in [>=M, <N] || [>N, <P] || [>P, <Q] where unEqualConstraints currently contains
// [>=M, !=N] already and we only want to add !=P right now
if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
$unEqualConstraints[] = $interval->getStart();
}
$unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
continue;
}
}
if (\count($unEqualConstraints) > 0) {
// this is where the end of the following interval of a != constraint is added as explained above
if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
$unEqualConstraints[] = $interval->getEnd();
}
// count is 1 if entire constraint is just one != expression
if (\count($unEqualConstraints) > 1) {
$constraints[] = new MultiConstraint($unEqualConstraints, true);
} else {
$constraints[] = $unEqualConstraints[0];
}
$unEqualConstraints = array();
continue;
}
// convert back >= x - <= x intervals to == x
if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
$constraints[] = new Constraint('==', $interval->getStart()->getVersion());
continue;
}
if ((string) $interval->getStart() === (string) Interval::fromZero()) {
$constraints[] = $interval->getEnd();
} elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
$constraints[] = $interval->getStart();
} else {
$constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
}
}
}
$devConstraints = array();
if (0 === \count($intervals['branches']['names'])) {
if ($intervals['branches']['exclude']) {
if ($hasNumericMatchAll) {
return new MatchAllConstraint;
}
// otherwise constraint should contain a != operator and already cover this
}
} else {
foreach ($intervals['branches']['names'] as $branchName) {
if ($intervals['branches']['exclude']) {
$devConstraints[] = new Constraint('!=', $branchName);
} else {
$devConstraints[] = new Constraint('==', $branchName);
}
}
// excluded branches, e.g. != dev-foo are conjunctive with the interval, so
// > 2.0 != dev-foo must return a conjunctive constraint
if ($intervals['branches']['exclude']) {
if (\count($constraints) > 1) {
return new MultiConstraint(array_merge(
array(new MultiConstraint($constraints, false)),
$devConstraints
), true);
}
if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
if (\count($devConstraints) > 1) {
return new MultiConstraint($devConstraints, true);
}
return $devConstraints[0];
}
return new MultiConstraint(array_merge($constraints, $devConstraints), true);
}
// otherwise devConstraints contains a list of == operators for branches which are disjunctive with the
// rest of the constraint
$constraints = array_merge($constraints, $devConstraints);
}
if (\count($constraints) > 1) {
return new MultiConstraint($constraints, false);
}
if (\count($constraints) === 1) {
return $constraints[0];
}
return new MatchNoneConstraint;
}
/**
* Creates an array of numeric intervals and branch constraints representing a given constraint
*
* if the returned numeric array is empty it means the constraint matches nothing in the numeric range (0 - +inf)
* if the returned branches array is empty it means no dev-* versions are matched
* if a constraint matches all possible dev-* versions, branches will contain Interval::anyDev()
*
* @return array
* @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
*/
public static function get(ConstraintInterface $constraint)
{
$key = (string) $constraint;
if (!isset(self::$intervalsCache[$key])) {
self::$intervalsCache[$key] = self::generateIntervals($constraint);
}
return self::$intervalsCache[$key];
}
/**
* @param bool $stopOnFirstValidInterval
*
* @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
*/
private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
{
if ($constraint instanceof MatchAllConstraint) {
return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
}
if ($constraint instanceof MatchNoneConstraint) {
return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
}
if ($constraint instanceof Constraint) {
return self::generateSingleConstraintIntervals($constraint);
}
if (!$constraint instanceof MultiConstraint) {
throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
}
$constraints = $constraint->getConstraints();
$numericGroups = array();
$constraintBranches = array();
foreach ($constraints as $c) {
$res = self::get($c);
$numericGroups[] = $res['numeric'];
$constraintBranches[] = $res['branches'];
}
if ($constraint->isDisjunctive()) {
$branches = Interval::noDev();
foreach ($constraintBranches as $b) {
if ($b['exclude']) {
if ($branches['exclude']) {
// disjunctive constraint, so only exclude what's excluded in all constraints
// !=a,!=b || !=b,!=c => !=b
$branches['names'] = array_intersect($branches['names'], $b['names']);
} else {
// disjunctive constraint so exclude all names which are not explicitly included in the alternative
// (==b || ==c) || !=a,!=b => !=a
$branches['exclude'] = true;
$branches['names'] = array_diff($b['names'], $branches['names']);
}
} else {
if ($branches['exclude']) {
// disjunctive constraint so exclude all names which are not explicitly included in the alternative
// !=a,!=b || (==b || ==c) => !=a
$branches['names'] = array_diff($branches['names'], $b['names']);
} else {
// disjunctive constraint, so just add all the other branches
// (==a || ==b) || ==c => ==a || ==b || ==c
$branches['names'] = array_merge($branches['names'], $b['names']);
}
}
}
} else {
$branches = Interval::anyDev();
foreach ($constraintBranches as $b) {
if ($b['exclude']) {
if ($branches['exclude']) {
// conjunctive, so just add all branch names to be excluded
// !=a && !=b => !=a,!=b
$branches['names'] = array_merge($branches['names'], $b['names']);
} else {
// conjunctive, so only keep included names which are not excluded
// (==a||==c) && !=a,!=b => ==c
$branches['names'] = array_diff($branches['names'], $b['names']);
}
} else {
if ($branches['exclude']) {
// conjunctive, so only keep included names which are not excluded
// !=a,!=b && (==a||==c) => ==c
$branches['names'] = array_diff($b['names'], $branches['names']);
$branches['exclude'] = false;
} else {
// conjunctive, so only keep names that are included in both
// (==a||==b) && (==a||==c) => ==a
$branches['names'] = array_intersect($branches['names'], $b['names']);
}
}
}
}
$branches['names'] = array_unique($branches['names']);
if (\count($numericGroups) === 1) {
return array('numeric' => $numericGroups[0], 'branches' => $branches);
}
$borders = array();
foreach ($numericGroups as $group) {
foreach ($group as $interval) {
$borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
$borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
}
}
$opSortOrder = self::$opSortOrder;
usort($borders, function ($a, $b) use ($opSortOrder) {
$order = version_compare($a['version'], $b['version']);
if ($order === 0) {
return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
}
return $order;
});
$activeIntervals = 0;
$intervals = array();
$index = 0;
$activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
$start = null;
foreach ($borders as $border) {
if ($border['side'] === 'start') {
$activeIntervals++;
} else {
$activeIntervals--;
}
if (!$start && $activeIntervals >= $activationThreshold) {
$start = new Constraint($border['operator'], $border['version']);
} elseif ($start && $activeIntervals < $activationThreshold) {
// filter out invalid intervals like > x - <= x, or >= x - < x
if (
version_compare($start->getVersion(), $border['version'], '=')
&& (
($start->getOperator() === '>' && $border['operator'] === '<=')
|| ($start->getOperator() === '>=' && $border['operator'] === '<')
)
) {
unset($intervals[$index]);
} else {
$intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
$index++;
if ($stopOnFirstValidInterval) {
break;
}
}
$start = null;
}
}
return array('numeric' => $intervals, 'branches' => $branches);
}
/**
* @phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
*/
private static function generateSingleConstraintIntervals(Constraint $constraint)
{
$op = $constraint->getOperator();
// handle branch constraints first
if (strpos($constraint->getVersion(), 'dev-') === 0) {
$intervals = array();
$branches = array('names' => array(), 'exclude' => false);
// != dev-foo means any numeric version may match, we treat >/< like != they are not really defined for branches
if ($op === '!=') {
$intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
$branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
} elseif ($op === '==') {
$branches['names'][] = $constraint->getVersion();
}
return array(
'numeric' => $intervals,
'branches' => $branches,
);
}
if ($op[0] === '>') { // > & >=
return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
}
if ($op[0] === '<') { // < & <=
return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
}
if ($op === '!=') {
// convert !=x to intervals of 0 - <x && >x - +inf + dev*
return array('numeric' => array(
new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
), 'branches' => Interval::anyDev());
}
// convert ==x to an interval of >=x - <=x
return array('numeric' => array(
new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
), 'branches' => Interval::noDev());
}
}

View File

@ -1,129 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\Constraint;
class Semver
{
const SORT_ASC = 1;
const SORT_DESC = -1;
/** @var VersionParser */
private static $versionParser;
/**
* Determine if given version satisfies given constraints.
*
* @param string $version
* @param string $constraints
*
* @return bool
*/
public static function satisfies($version, $constraints)
{
if (null === self::$versionParser) {
self::$versionParser = new VersionParser();
}
$versionParser = self::$versionParser;
$provider = new Constraint('==', $versionParser->normalize($version));
$parsedConstraints = $versionParser->parseConstraints($constraints);
return $parsedConstraints->matches($provider);
}
/**
* Return all versions that satisfy given constraints.
*
* @param string[] $versions
* @param string $constraints
*
* @return string[]
*/
public static function satisfiedBy(array $versions, $constraints)
{
$versions = array_filter($versions, function ($version) use ($constraints) {
return Semver::satisfies($version, $constraints);
});
return array_values($versions);
}
/**
* Sort given array of versions.
*
* @param string[] $versions
*
* @return string[]
*/
public static function sort(array $versions)
{
return self::usort($versions, self::SORT_ASC);
}
/**
* Sort given array of versions in reverse.
*
* @param string[] $versions
*
* @return string[]
*/
public static function rsort(array $versions)
{
return self::usort($versions, self::SORT_DESC);
}
/**
* @param string[] $versions
* @param int $direction
*
* @return string[]
*/
private static function usort(array $versions, $direction)
{
if (null === self::$versionParser) {
self::$versionParser = new VersionParser();
}
$versionParser = self::$versionParser;
$normalized = array();
// Normalize outside of usort() scope for minor performance increase.
// Creates an array of arrays: [[normalized, key], ...]
foreach ($versions as $key => $version) {
$normalizedVersion = $versionParser->normalize($version);
$normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
$normalized[] = array($normalizedVersion, $key);
}
usort($normalized, function (array $left, array $right) use ($direction) {
if ($left[0] === $right[0]) {
return 0;
}
if (Comparator::lessThan($left[0], $right[0])) {
return -$direction;
}
return $direction;
});
// Recreate input array, using the original indexes which are now in sorted order.
$sorted = array();
foreach ($normalized as $item) {
$sorted[] = $versions[$item[1]];
}
return $sorted;
}
}

View File

@ -1,591 +0,0 @@
<?php
/*
* This file is part of composer/semver.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\Semver;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Semver\Constraint\MultiConstraint;
use Composer\Semver\Constraint\Constraint;
/**
* Version parser.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class VersionParser
{
/**
* Regex to match pre-release data (sort of).
*
* Due to backwards compatibility:
* - Instead of enforcing hyphen, an underscore, dot or nothing at all are also accepted.
* - Only stabilities as recognized by Composer are allowed to precede a numerical identifier.
* - Numerical-only pre-release identifiers are not supported, see tests.
*
* |--------------|
* [major].[minor].[patch] -[pre-release] +[build-metadata]
*
* @var string
*/
private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
/** @var string */
private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
/**
* Returns the stability of a version.
*
* @param string $version
*
* @return string
* @phpstan-return 'stable'|'RC'|'beta'|'alpha'|'dev'
*/
public static function parseStability($version)
{
$version = (string) preg_replace('{#.+$}', '', (string) $version);
if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
return 'dev';
}
preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
if (!empty($match[3])) {
return 'dev';
}
if (!empty($match[1])) {
if ('beta' === $match[1] || 'b' === $match[1]) {
return 'beta';
}
if ('alpha' === $match[1] || 'a' === $match[1]) {
return 'alpha';
}
if ('rc' === $match[1]) {
return 'RC';
}
}
return 'stable';
}
/**
* @param string $stability
*
* @return string
* @phpstan-return 'stable'|'RC'|'beta'|'alpha'|'dev'
*/
public static function normalizeStability($stability)
{
$stability = strtolower((string) $stability);
if (!in_array($stability, array('stable', 'rc', 'beta', 'alpha', 'dev'), true)) {
throw new \InvalidArgumentException('Invalid stability string "'.$stability.'", expected one of stable, RC, beta, alpha or dev');
}
return $stability === 'rc' ? 'RC' : $stability;
}
/**
* Normalizes a version string to be able to perform comparisons on it.
*
* @param string $version
* @param ?string $fullVersion optional complete version string to give more context
*
* @throws \UnexpectedValueException
*
* @return string
*/
public function normalize($version, $fullVersion = null)
{
$version = trim((string) $version);
$origVersion = $version;
if (null === $fullVersion) {
$fullVersion = $version;
}
// strip off aliasing
if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
$version = $match[1];
}
// strip off stability flag
if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
$version = substr($version, 0, strlen($version) - strlen($match[0]));
}
// normalize master/trunk/default branches to dev-name for BC with 1.x as these used to be valid constraints
if (\in_array($version, array('master', 'trunk', 'default'), true)) {
$version = 'dev-' . $version;
}
// if requirement is branch-like, use full name
if (stripos($version, 'dev-') === 0) {
return 'dev-' . substr($version, 4);
}
// strip off build metadata
if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
$version = $match[1];
}
// match classical versioning
if (preg_match('{^v?(\d{1,5}+)(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = $matches[1]
. (!empty($matches[2]) ? $matches[2] : '.0')
. (!empty($matches[3]) ? $matches[3] : '.0')
. (!empty($matches[4]) ? $matches[4] : '.0');
$index = 5;
// match date(time) based versioning
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3}){0,2})' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = (string) preg_replace('{\D}', '.', $matches[1]);
$index = 2;
}
// add version modifiers if a version was matched
if (isset($index)) {
if (!empty($matches[$index])) {
if ('stable' === $matches[$index]) {
return $version;
}
$version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
}
if (!empty($matches[$index + 2])) {
$version .= '-dev';
}
return $version;
}
// match dev branches
if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
try {
$normalized = $this->normalizeBranch($match[1]);
// a branch ending with -dev is only valid if it is numeric
// if it gets prefixed with dev- it means the branch name should
// have had a dev- prefix already when passed to normalize
if (strpos($normalized, 'dev-') === false) {
return $normalized;
}
} catch (\Exception $e) {
}
}
$extraMessage = '';
if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
$extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
} elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
$extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
}
throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
}
/**
* Extract numeric prefix from alias, if it is in numeric format, suitable for version comparison.
*
* @param string $branch Branch name (e.g. 2.1.x-dev)
*
* @return string|false Numeric prefix if present (e.g. 2.1.) or false
*/
public function parseNumericAliasPrefix($branch)
{
if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', (string) $branch, $matches)) {
return $matches['version'] . '.';
}
return false;
}
/**
* Normalizes a branch name to be able to perform comparisons on it.
*
* @param string $name
*
* @return string
*/
public function normalizeBranch($name)
{
$name = trim((string) $name);
if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
$version = '';
for ($i = 1; $i < 5; ++$i) {
$version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
}
return str_replace('x', '9999999', $version) . '-dev';
}
return 'dev-' . $name;
}
/**
* Normalizes a default branch name (i.e. master on git) to 9999999-dev.
*
* @param string $name
*
* @return string
*
* @deprecated No need to use this anymore in theory, Composer 2 does not normalize any branch names to 9999999-dev anymore
*/
public function normalizeDefaultBranch($name)
{
if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
return '9999999-dev';
}
return (string) $name;
}
/**
* Parses a constraint string into MultiConstraint and/or Constraint objects.
*
* @param string $constraints
*
* @return ConstraintInterface
*/
public function parseConstraints($constraints)
{
$prettyConstraint = (string) $constraints;
$orConstraints = preg_split('{\s*\|\|?\s*}', trim((string) $constraints));
if (false === $orConstraints) {
throw new \RuntimeException('Failed to preg_split string: '.$constraints);
}
$orGroups = array();
foreach ($orConstraints as $orConstraint) {
$andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
if (false === $andConstraints) {
throw new \RuntimeException('Failed to preg_split string: '.$orConstraint);
}
if (\count($andConstraints) > 1) {
$constraintObjects = array();
foreach ($andConstraints as $andConstraint) {
foreach ($this->parseConstraint($andConstraint) as $parsedAndConstraint) {
$constraintObjects[] = $parsedAndConstraint;
}
}
} else {
$constraintObjects = $this->parseConstraint($andConstraints[0]);
}
if (1 === \count($constraintObjects)) {
$constraint = $constraintObjects[0];
} else {
$constraint = new MultiConstraint($constraintObjects);
}
$orGroups[] = $constraint;
}
$parsedConstraint = MultiConstraint::create($orGroups, false);
$parsedConstraint->setPrettyString($prettyConstraint);
return $parsedConstraint;
}
/**
* @param string $constraint
*
* @throws \UnexpectedValueException
*
* @return array
*
* @phpstan-return non-empty-array<ConstraintInterface>
*/
private function parseConstraint($constraint)
{
// strip off aliasing
if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
$constraint = $match[1];
}
// strip @stability flags, and keep it for later use
if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
$constraint = '' !== $match[1] ? $match[1] : '*';
if ($match[2] !== 'stable') {
$stabilityModifier = $match[2];
}
}
// get rid of #refs as those are used by composer only
if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
$constraint = $match[1];
}
if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
if (!empty($match[1]) || !empty($match[2])) {
return array(new Constraint('>=', '0.0.0.0-dev'));
}
return array(new MatchAllConstraint());
}
$versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
// Tilde Range
//
// Like wildcard constraints, unsuffixed tilde constraints say that they must be greater than the previous
// version, to ensure that unstable instances of the current version are allowed. However, if a stability
// suffix is added to the constraint, then a >= match on the current version is used instead.
if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
if (strpos($constraint, '~>') === 0) {
throw new \UnexpectedValueException(
'Could not parse version constraint ' . $constraint . ': ' .
'Invalid operator "~>", you probably meant to use the "~" operator'
);
}
// Work out which position in the version we are operating at
if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
$position = 4;
} elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
$position = 3;
} elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
$position = 2;
} else {
$position = 1;
}
// when matching 2.x-dev or 3.0.x-dev we have to shift the second or third number, despite no second/third number matching above
if (!empty($matches[8])) {
$position++;
}
// Calculate the stability suffix
$stabilitySuffix = '';
if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
$stabilitySuffix .= '-dev';
}
$lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
$lowerBound = new Constraint('>=', $lowVersion);
// For upper bound, we increment the position of one more significance,
// but highPosition = 0 would be illegal
$highPosition = max(1, $position - 1);
$highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
$upperBound = new Constraint('<', $highVersion);
return array(
$lowerBound,
$upperBound,
);
}
// Caret Range
//
// Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple.
// In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for
// versions 0.X >=0.1.0, and no updates for versions 0.0.X
if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
// Work out which position in the version we are operating at
if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
$position = 1;
} elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
$position = 2;
} else {
$position = 3;
}
// Calculate the stability suffix
$stabilitySuffix = '';
if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
$stabilitySuffix .= '-dev';
}
$lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
$lowerBound = new Constraint('>=', $lowVersion);
// For upper bound, we increment the position of one more significance,
// but highPosition = 0 would be illegal
$highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
$upperBound = new Constraint('<', $highVersion);
return array(
$lowerBound,
$upperBound,
);
}
// X Range
//
// Any of X, x, or * may be used to "stand in" for one of the numeric values in the [major, minor, patch] tuple.
// A partial version range is treated as an X-Range, so the special character is in fact optional.
if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
$position = 3;
} elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
$position = 2;
} else {
$position = 1;
}
$lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
$highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
if ($lowVersion === '0.0.0.0-dev') {
return array(new Constraint('<', $highVersion));
}
return array(
new Constraint('>=', $lowVersion),
new Constraint('<', $highVersion),
);
}
// Hyphen Range
//
// Specifies an inclusive set. If a partial version is provided as the first version in the inclusive range,
// then the missing pieces are replaced with zeroes. If a partial version is provided as the second version in
// the inclusive range, then all versions that start with the supplied parts of the tuple are accepted, but
// nothing that would be greater than the provided tuple parts.
if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
// Calculate the stability suffix
$lowStabilitySuffix = '';
if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
$lowStabilitySuffix = '-dev';
}
$lowVersion = $this->normalize($matches['from']);
$lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
$empty = function ($x) {
return ($x === 0 || $x === '0') ? false : empty($x);
};
if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
$highVersion = $this->normalize($matches['to']);
$upperBound = new Constraint('<=', $highVersion);
} else {
$highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
// validate to version
$this->normalize($matches['to']);
$highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
$upperBound = new Constraint('<', $highVersion);
}
return array(
$lowerBound,
$upperBound,
);
}
// Basic Comparators
if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
try {
try {
$version = $this->normalize($matches[2]);
} catch (\UnexpectedValueException $e) {
// recover from an invalid constraint like foobar-dev which should be dev-foobar
// except if the constraint uses a known operator, in which case it must be a parse error
if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
$version = $this->normalize('dev-'.substr($matches[2], 0, -4));
} else {
throw $e;
}
}
$op = $matches[1] ?: '=';
if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
$version .= '-' . $stabilityModifier;
} elseif ('<' === $op || '>=' === $op) {
if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
if (strpos($matches[2], 'dev-') !== 0) {
$version .= '-dev';
}
}
}
return array(new Constraint($matches[1] ?: '=', $version));
} catch (\Exception $e) {
}
}
$message = 'Could not parse version constraint ' . $constraint;
if (isset($e)) {
$message .= ': ' . $e->getMessage();
}
throw new \UnexpectedValueException($message);
}
/**
* Increment, decrement, or simply pad a version number.
*
* Support function for {@link parseConstraint()}
*
* @param array $matches Array with version parts in array indexes 1,2,3,4
* @param int $position 1,2,3,4 - which segment of the version to increment/decrement
* @param int $increment
* @param string $pad The string to pad version parts after $position
*
* @return string|null The new version
*
* @phpstan-param string[] $matches
*/
private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
{
for ($i = 4; $i > 0; --$i) {
if ($i > $position) {
$matches[$i] = $pad;
} elseif ($i === $position && $increment) {
$matches[$i] += $increment;
// If $matches[$i] was 0, carry the decrement
if ($matches[$i] < 0) {
$matches[$i] = $pad;
--$position;
// Return null on a carry overflow
if ($i === 1) {
return null;
}
}
}
}
return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
}
/**
* Expand shorthand stability string to long version.
*
* @param string $stability
*
* @return string
*/
private function expandStability($stability)
{
$stability = strtolower($stability);
switch ($stability) {
case 'a':
return 'alpha';
case 'b':
return 'beta';
case 'p':
case 'pl':
return 'patch';
case 'rc':
return 'RC';
default:
return $stability;
}
}
}

View File

@ -1,143 +0,0 @@
## [Unreleased]
## [3.0.5] - 2024-05-06
* Fixed: fail restart if PHP_BINARY is not available
## [3.0.4] - 2024-03-26
* Added: Functional tests.
* Fixed: Incompatibility with PHPUnit 10.
## [3.0.3] - 2022-02-25
* Added: support for composer/pcre versions 2 and 3.
## [3.0.2] - 2022-02-24
* Fixed: regression in 3.0.1 affecting Xdebug 2
## [3.0.1] - 2022-01-04
* Fixed: error when calling `isXdebugActive` before class instantiation.
## [3.0.0] - 2021-12-23
* Removed: support for legacy PHP versions (< PHP 7.2.5).
* Added: type declarations to arguments and return values.
* Added: strict typing to all classes.
## [2.0.3] - 2021-12-08
* Added: support, type annotations and refactoring for stricter PHPStan analysis.
## [2.0.2] - 2021-07-31
* Added: support for `xdebug_info('mode')` in Xdebug 3.1.
* Added: support for Psr\Log versions 2 and 3.
* Fixed: remove ini directives from non-cli HOST/PATH sections.
## [2.0.1] - 2021-05-05
* Fixed: don't restart if the cwd is a UNC path and cmd.exe will be invoked.
## [2.0.0] - 2021-04-09
* Break: this is a major release, see [UPGRADE.md](UPGRADE.md) for more information.
* Break: removed optional `$colorOption` constructor param and passthru fallback.
* Break: renamed `requiresRestart` param from `$isLoaded` to `$default`.
* Break: changed `restart` param `$command` from a string to an array.
* Added: support for Xdebug3 to only restart if Xdebug is not running with `xdebug.mode=off`.
* Added: `isXdebugActive()` method to determine if Xdebug is still running in the restart.
* Added: feature to bypass the shell in PHP-7.4+ by giving `proc_open` an array of arguments.
* Added: Process utility class to the API.
## [1.4.6] - 2021-03-25
* Fixed: fail restart if `proc_open` has been disabled in `disable_functions`.
* Fixed: enable Windows CTRL event handling in the restarted process.
## [1.4.5] - 2020-11-13
* Fixed: use `proc_open` when available for correct FD forwarding to the restarted process.
## [1.4.4] - 2020-10-24
* Fixed: exception if 'pcntl_signal' is disabled.
## [1.4.3] - 2020-08-19
* Fixed: restore SIGINT to default handler in restarted process if no other handler exists.
## [1.4.2] - 2020-06-04
* Fixed: ignore SIGINTs to let the restarted process handle them.
## [1.4.1] - 2020-03-01
* Fixed: restart fails if an ini file is empty.
## [1.4.0] - 2019-11-06
* Added: support for `NO_COLOR` environment variable: https://no-color.org
* Added: color support for Hyper terminal: https://github.com/zeit/hyper
* Fixed: correct capitalization of Xdebug (apparently).
* Fixed: improved handling for uopz extension.
## [1.3.3] - 2019-05-27
* Fixed: add environment changes to `$_ENV` if it is being used.
## [1.3.2] - 2019-01-28
* Fixed: exit call being blocked by uopz extension, resulting in application code running twice.
## [1.3.1] - 2018-11-29
* Fixed: fail restart if `passthru` has been disabled in `disable_functions`.
* Fixed: fail restart if an ini file cannot be opened, otherwise settings will be missing.
## [1.3.0] - 2018-08-31
* Added: `setPersistent` method to use environment variables for the restart.
* Fixed: improved debugging by writing output to stderr.
* Fixed: no restart when `php_ini_scanned_files` is not functional and is needed.
## [1.2.1] - 2018-08-23
* Fixed: fatal error with apc, when using `apc.mmap_file_mask`.
## [1.2.0] - 2018-08-16
* Added: debug information using `XDEBUG_HANDLER_DEBUG`.
* Added: fluent interface for setters.
* Added: `PhpConfig` helper class for calling PHP sub-processes.
* Added: `PHPRC` original value to restart stettings, for use in a restarted process.
* Changed: internal procedure to disable ini-scanning, using `-n` command-line option.
* Fixed: replaced `escapeshellarg` usage to avoid locale problems.
* Fixed: improved color-option handling to respect double-dash delimiter.
* Fixed: color-option handling regression from main script changes.
* Fixed: improved handling when checking main script.
* Fixed: handling for standard input, that never actually did anything.
* Fixed: fatal error when ctype extension is not available.
## [1.1.0] - 2018-04-11
* Added: `getRestartSettings` method for calling PHP processes in a restarted process.
* Added: API definition and @internal class annotations.
* Added: protected `requiresRestart` method for extending classes.
* Added: `setMainScript` method for applications that change the working directory.
* Changed: private `tmpIni` variable to protected for extending classes.
* Fixed: environment variables not available in $_SERVER when restored in the restart.
* Fixed: relative path problems caused by Phar::interceptFileFuncs.
* Fixed: incorrect handling when script file cannot be found.
## [1.0.0] - 2018-03-08
* Added: PSR3 logging for optional status output.
* Added: existing ini settings are merged to catch command-line overrides.
* Added: code, tests and other artefacts to decouple from Composer.
* Break: the following class was renamed:
- `Composer\XdebugHandler` -> `Composer\XdebugHandler\XdebugHandler`
[Unreleased]: https://github.com/composer/xdebug-handler/compare/3.0.5...HEAD
[3.0.5]: https://github.com/composer/xdebug-handler/compare/3.0.4...3.0.5
[3.0.4]: https://github.com/composer/xdebug-handler/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/composer/xdebug-handler/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/composer/xdebug-handler/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/composer/xdebug-handler/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/composer/xdebug-handler/compare/2.0.3...3.0.0
[2.0.3]: https://github.com/composer/xdebug-handler/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/composer/xdebug-handler/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/composer/xdebug-handler/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/composer/xdebug-handler/compare/1.4.6...2.0.0
[1.4.6]: https://github.com/composer/xdebug-handler/compare/1.4.5...1.4.6
[1.4.5]: https://github.com/composer/xdebug-handler/compare/1.4.4...1.4.5
[1.4.4]: https://github.com/composer/xdebug-handler/compare/1.4.3...1.4.4
[1.4.3]: https://github.com/composer/xdebug-handler/compare/1.4.2...1.4.3
[1.4.2]: https://github.com/composer/xdebug-handler/compare/1.4.1...1.4.2
[1.4.1]: https://github.com/composer/xdebug-handler/compare/1.4.0...1.4.1
[1.4.0]: https://github.com/composer/xdebug-handler/compare/1.3.3...1.4.0
[1.3.3]: https://github.com/composer/xdebug-handler/compare/1.3.2...1.3.3
[1.3.2]: https://github.com/composer/xdebug-handler/compare/1.3.1...1.3.2
[1.3.1]: https://github.com/composer/xdebug-handler/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/composer/xdebug-handler/compare/1.2.1...1.3.0
[1.2.1]: https://github.com/composer/xdebug-handler/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/composer/xdebug-handler/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/composer/xdebug-handler/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/composer/xdebug-handler/compare/d66f0d15cb57...1.0.0

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2017 Composer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,305 +0,0 @@
# composer/xdebug-handler
[![packagist](https://img.shields.io/packagist/v/composer/xdebug-handler)](https://packagist.org/packages/composer/xdebug-handler)
[![Continuous Integration](https://github.com/composer/xdebug-handler/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/composer/xdebug-handler/actions?query=branch:main)
![license](https://img.shields.io/github/license/composer/xdebug-handler.svg)
![php](https://img.shields.io/packagist/php-v/composer/xdebug-handler?colorB=8892BF)
Restart a CLI process without loading the Xdebug extension, unless `xdebug.mode=off`.
Originally written as part of [composer/composer](https://github.com/composer/composer),
now extracted and made available as a stand-alone library.
### Version 3
Removed support for legacy PHP versions and added type declarations.
Long term support for version 2 (PHP 5.3.2 - 7.2.4) follows [Composer 2.2 LTS](https://blog.packagist.com/composer-2-2/) policy.
## Installation
Install the latest version with:
```bash
$ composer require composer/xdebug-handler
```
## Requirements
* PHP 7.2.5 minimum, although using the latest PHP version is highly recommended.
## Basic Usage
```php
use Composer\XdebugHandler\XdebugHandler;
$xdebug = new XdebugHandler('myapp');
$xdebug->check();
unset($xdebug);
```
The constructor takes a single parameter, `$envPrefix`, which is upper-cased and prepended to default base values to create two distinct environment variables. The above example enables the use of:
- `MYAPP_ALLOW_XDEBUG=1` to override automatic restart and allow Xdebug
- `MYAPP_ORIGINAL_INIS` to obtain ini file locations in a restarted process
## Advanced Usage
* [How it works](#how-it-works)
* [Limitations](#limitations)
* [Helper methods](#helper-methods)
* [Setter methods](#setter-methods)
* [Process configuration](#process-configuration)
* [Troubleshooting](#troubleshooting)
* [Extending the library](#extending-the-library)
* [Examples](#examples)
### How it works
A temporary ini file is created from the loaded (and scanned) ini files, with any references to the Xdebug extension commented out. Current ini settings are merged, so that most ini settings made on the command-line or by the application are included (see [Limitations](#limitations))
* `MYAPP_ALLOW_XDEBUG` is set with internal data to flag and use in the restart.
* The command-line and environment are [configured](#process-configuration) for the restart.
* The application is restarted in a new process.
* The restart settings are stored in the environment.
* `MYAPP_ALLOW_XDEBUG` is unset.
* The application runs and exits.
* The main process exits with the exit code from the restarted process.
See [Examples](#examples) for further information.
#### Signal handling
Asynchronous signal handling is automatically enabled if the pcntl extension is loaded. `SIGINT` is set to `SIG_IGN` in the parent
process and restored to `SIG_DFL` in the restarted process (if no other handler has been set).
From PHP 7.4 on Windows, `CTRL+C` and `CTRL+BREAK` handling is automatically enabled in the restarted process and ignored in the parent process.
### Limitations
There are a few things to be aware of when running inside a restarted process.
* Extensions set on the command-line will not be loaded.
* Ini file locations will be reported as per the restart - see [getAllIniFiles()](#getallinifiles-array).
* Php sub-processes may be loaded with Xdebug enabled - see [Process configuration](#process-configuration).
### Helper methods
These static methods provide information from the current process, regardless of whether it has been restarted or not.
#### _getAllIniFiles(): array_
Returns an array of the original ini file locations. Use this instead of calling `php_ini_loaded_file` and `php_ini_scanned_files`, which will report the wrong values in a restarted process.
```php
use Composer\XdebugHandler\XdebugHandler;
$files = XdebugHandler::getAllIniFiles();
# $files[0] always exists, it could be an empty string
$loadedIni = array_shift($files);
$scannedInis = $files;
```
These locations are also available in the `MYAPP_ORIGINAL_INIS` environment variable. This is a path-separated string comprising the location returned from `php_ini_loaded_file`, which could be empty, followed by locations parsed from calling `php_ini_scanned_files`.
#### _getRestartSettings(): ?array_
Returns an array of settings that can be used with PHP [sub-processes](#sub-processes), or null if the process was not restarted.
```php
use Composer\XdebugHandler\XdebugHandler;
$settings = XdebugHandler::getRestartSettings();
/**
* $settings: array (if the current process was restarted,
* or called with the settings from a previous restart), or null
*
* 'tmpIni' => the temporary ini file used in the restart (string)
* 'scannedInis' => if there were any scanned inis (bool)
* 'scanDir' => the original PHP_INI_SCAN_DIR value (false|string)
* 'phprc' => the original PHPRC value (false|string)
* 'inis' => the original inis from getAllIniFiles (array)
* 'skipped' => the skipped version from getSkippedVersion (string)
*/
```
#### _getSkippedVersion(): string_
Returns the Xdebug version string that was skipped by the restart, or an empty string if there was no restart (or Xdebug is still loaded, perhaps by an extending class restarting for a reason other than removing Xdebug).
```php
use Composer\XdebugHandler\XdebugHandler;
$version = XdebugHandler::getSkippedVersion();
# $version: '3.1.1' (for example), or an empty string
```
#### _isXdebugActive(): bool_
Returns true if Xdebug is loaded and is running in an active mode (if it supports modes). Returns false if Xdebug is not loaded, or it is running with `xdebug.mode=off`.
### Setter methods
These methods implement a fluent interface and must be called before the main `check()` method.
#### _setLogger(LoggerInterface $logger): self_
Enables the output of status messages to an external PSR3 logger. All messages are reported with either `DEBUG` or `WARNING` log levels. For example (showing the level and message):
```
// No restart
DEBUG Checking MYAPP_ALLOW_XDEBUG
DEBUG The Xdebug extension is loaded (3.1.1) xdebug.mode=off
DEBUG No restart (APP_ALLOW_XDEBUG=0) Allowed by xdebug.mode
// Restart overridden
DEBUG Checking MYAPP_ALLOW_XDEBUG
DEBUG The Xdebug extension is loaded (3.1.1) xdebug.mode=coverage,debug,develop
DEBUG No restart (MYAPP_ALLOW_XDEBUG=1)
// Failed restart
DEBUG Checking MYAPP_ALLOW_XDEBUG
DEBUG The Xdebug extension is loaded (3.1.0)
WARNING No restart (Unable to create temp ini file at: ...)
```
Status messages can also be output with `XDEBUG_HANDLER_DEBUG`. See [Troubleshooting](#troubleshooting).
#### _setMainScript(string $script): self_
Sets the location of the main script to run in the restart. This is only needed in more esoteric use-cases, or if the `argv[0]` location is inaccessible. The script name `--` is supported for standard input.
#### _setPersistent(): self_
Configures the restart using [persistent settings](#persistent-settings), so that Xdebug is not loaded in any sub-process.
Use this method if your application invokes one or more PHP sub-process and the Xdebug extension is not needed. This avoids the overhead of implementing specific [sub-process](#sub-processes) strategies.
Alternatively, this method can be used to set up a default _Xdebug-free_ environment which can be changed if a sub-process requires Xdebug, then restored afterwards:
```php
function SubProcessWithXdebug()
{
$phpConfig = new Composer\XdebugHandler\PhpConfig();
# Set the environment to the original configuration
$phpConfig->useOriginal();
# run the process with Xdebug loaded
...
# Restore Xdebug-free environment
$phpConfig->usePersistent();
}
```
### Process configuration
The library offers two strategies to invoke a new PHP process without loading Xdebug, using either _standard_ or _persistent_ settings. Note that this is only important if the application calls a PHP sub-process.
#### Standard settings
Uses command-line options to remove Xdebug from the new process only.
* The -n option is added to the command-line. This tells PHP not to scan for additional inis.
* The temporary ini is added to the command-line with the -c option.
>_If the new process calls a PHP sub-process, Xdebug will be loaded in that sub-process (unless it implements xdebug-handler, in which case there will be another restart)._
This is the default strategy used in the restart.
#### Persistent settings
Uses environment variables to remove Xdebug from the new process and persist these settings to any sub-process.
* `PHP_INI_SCAN_DIR` is set to an empty string. This tells PHP not to scan for additional inis.
* `PHPRC` is set to the temporary ini.
>_If the new process calls a PHP sub-process, Xdebug will not be loaded in that sub-process._
This strategy can be used in the restart by calling [setPersistent()](#setpersistent-self).
#### Sub-processes
The `PhpConfig` helper class makes it easy to invoke a PHP sub-process (with or without Xdebug loaded), regardless of whether there has been a restart.
Each of its methods returns an array of PHP options (to add to the command-line) and sets up the environment for the required strategy. The [getRestartSettings()](#getrestartsettings-array) method is used internally.
* `useOriginal()` - Xdebug will be loaded in the new process.
* `useStandard()` - Xdebug will **not** be loaded in the new process - see [standard settings](#standard-settings).
* `userPersistent()` - Xdebug will **not** be loaded in the new process - see [persistent settings](#persistent-settings)
If there was no restart, an empty options array is returned and the environment is not changed.
```php
use Composer\XdebugHandler\PhpConfig;
$config = new PhpConfig;
$options = $config->useOriginal();
# $options: empty array
# environment: PHPRC and PHP_INI_SCAN_DIR set to original values
$options = $config->useStandard();
# $options: [-n, -c, tmpIni]
# environment: PHPRC and PHP_INI_SCAN_DIR set to original values
$options = $config->usePersistent();
# $options: empty array
# environment: PHPRC=tmpIni, PHP_INI_SCAN_DIR=''
```
### Troubleshooting
The following environment settings can be used to troubleshoot unexpected behavior:
* `XDEBUG_HANDLER_DEBUG=1` Outputs status messages to `STDERR`, if it is defined, irrespective of any PSR3 logger. Each message is prefixed `xdebug-handler[pid]`, where pid is the process identifier.
* `XDEBUG_HANDLER_DEBUG=2` As above, but additionally saves the temporary ini file and reports its location in a status message.
### Extending the library
The API is defined by classes and their accessible elements that are not annotated as @internal. The main class has two protected methods that can be overridden to provide additional functionality:
#### _requiresRestart(bool $default): bool_
By default the process will restart if Xdebug is loaded and not running with `xdebug.mode=off`. Extending this method allows an application to decide, by returning a boolean (or equivalent) value.
It is only called if `MYAPP_ALLOW_XDEBUG` is empty, so it will not be called in the restarted process (where this variable contains internal data), or if the restart has been overridden.
Note that the [setMainScript()](#setmainscriptstring-script-self) and [setPersistent()](#setpersistent-self) setters can be used here, if required.
#### _restart(array $command): void_
An application can extend this to modify the temporary ini file, its location given in the `tmpIni` property. New settings can be safely appended to the end of the data, which is `PHP_EOL` terminated.
The `$command` parameter is an array of unescaped command-line arguments that will be used for the new process.
Remember to finish with `parent::restart($command)`.
#### Example
This example demonstrates two ways to extend basic functionality:
* To avoid the overhead of spinning up a new process, the restart is skipped if a simple help command is requested.
* The application needs write-access to phar files, so it will force a restart if `phar.readonly` is set (regardless of whether Xdebug is loaded) and change this value in the temporary ini file.
```php
use Composer\XdebugHandler\XdebugHandler;
use MyApp\Command;
class MyRestarter extends XdebugHandler
{
private $required;
protected function requiresRestart(bool $default): bool
{
if (Command::isHelp()) {
# No need to disable Xdebug for this
return false;
}
$this->required = (bool) ini_get('phar.readonly');
return $this->required || $default;
}
protected function restart(array $command): void
{
if ($this->required) {
# Add required ini setting to tmpIni
$content = file_get_contents($this->tmpIni);
$content .= 'phar.readonly=0'.PHP_EOL;
file_put_contents($this->tmpIni, $content);
}
parent::restart($command);
}
}
```
### Examples
The `tests\App` directory contains command-line scripts that demonstrate the internal workings in a variety of scenarios.
See [Functional Test Scripts](./tests/App/README.md).
## License
composer/xdebug-handler is licensed under the MIT License, see the LICENSE file for details.

View File

@ -1,44 +0,0 @@
{
"name": "composer/xdebug-handler",
"description": "Restarts a process without Xdebug.",
"type": "library",
"license": "MIT",
"keywords": [
"xdebug",
"performance"
],
"authors": [
{
"name": "John Stevenson",
"email": "john-stevenson@blueyonder.co.uk"
}
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/xdebug-handler/issues"
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/log": "^1 || ^2 || ^3",
"composer/pcre": "^1 || ^2 || ^3"
},
"require-dev": {
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
},
"autoload": {
"psr-4": {
"Composer\\XdebugHandler\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\XdebugHandler\\Tests\\": "tests"
}
},
"scripts": {
"test": "@php vendor/bin/phpunit",
"phpstan": "@php vendor/bin/phpstan analyse"
}
}

View File

@ -1,91 +0,0 @@
<?php
declare(strict_types=1);
/*
* This file is part of composer/xdebug-handler.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Composer\XdebugHandler;
/**
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
*
* @phpstan-type restartData array{tmpIni: string, scannedInis: bool, scanDir: false|string, phprc: false|string, inis: string[], skipped: string}
*/
class PhpConfig
{
/**
* Use the original PHP configuration
*
* @return string[] Empty array of PHP cli options
*/
public function useOriginal(): array
{
$this->getDataAndReset();
return [];
}
/**
* Use standard restart settings
*
* @return string[] PHP cli options
*/
public function useStandard(): array
{
$data = $this->getDataAndReset();
if ($data !== null) {
return ['-n', '-c', $data['tmpIni']];
}
return [];
}
/**
* Use environment variables to persist settings
*
* @return string[] Empty array of PHP cli options
*/
public function usePersistent(): array
{
$data = $this->getDataAndReset();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['tmpIni']);
$this->updateEnv('PHP_INI_SCAN_DIR', '');
}
return [];
}
/**
* Returns restart data if available and resets the environment
*
* @phpstan-return restartData|null
*/
private function getDataAndReset(): ?array
{
$data = XdebugHandler::getRestartSettings();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['phprc']);
$this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
}
return $data;
}
/**
* Updates a restart settings value in the environment
*
* @param string $name
* @param string|false $value
*/
private function updateEnv(string $name, $value): void
{
Process::setEnv($name, false !== $value ? $value : null);
}
}

View File

@ -1,119 +0,0 @@
<?php
/*
* This file is part of composer/xdebug-handler.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Composer\XdebugHandler;
use Composer\Pcre\Preg;
/**
* Process utility functions
*
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
*/
class Process
{
/**
* Escapes a string to be used as a shell argument.
*
* From https://github.com/johnstevenson/winbox-args
* MIT Licensed (c) John Stevenson <john-stevenson@blueyonder.co.uk>
*
* @param string $arg The argument to be escaped
* @param bool $meta Additionally escape cmd.exe meta characters
* @param bool $module The argument is the module to invoke
*/
public static function escape(string $arg, bool $meta = true, bool $module = false): string
{
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
return "'".str_replace("'", "'\\''", $arg)."'";
}
$quote = strpbrk($arg, " \t") !== false || $arg === '';
$arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
$dquotes = (bool) $dquotes;
if ($meta) {
$meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg);
if (!$meta) {
$quote = $quote || strpbrk($arg, '^&|<>()') !== false;
} elseif ($module && !$dquotes && $quote) {
$meta = false;
}
}
if ($quote) {
$arg = '"'.(Preg::replace('/(\\\\*)$/', '$1$1', $arg)).'"';
}
if ($meta) {
$arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
}
return $arg;
}
/**
* Escapes an array of arguments that make up a shell command
*
* @param string[] $args Argument list, with the module name first
*/
public static function escapeShellCommand(array $args): string
{
$command = '';
$module = array_shift($args);
if ($module !== null) {
$command = self::escape($module, true, true);
foreach ($args as $arg) {
$command .= ' '.self::escape($arg);
}
}
return $command;
}
/**
* Makes putenv environment changes available in $_SERVER and $_ENV
*
* @param string $name
* @param ?string $value A null value unsets the variable
*/
public static function setEnv(string $name, ?string $value = null): bool
{
$unset = null === $value;
if (!putenv($unset ? $name : $name.'='.$value)) {
return false;
}
if ($unset) {
unset($_SERVER[$name]);
} else {
$_SERVER[$name] = $value;
}
// Update $_ENV if it is being used
if (false !== stripos((string) ini_get('variables_order'), 'E')) {
if ($unset) {
unset($_ENV[$name]);
} else {
$_ENV[$name] = $value;
}
}
return true;
}
}

View File

@ -1,222 +0,0 @@
<?php
/*
* This file is part of composer/xdebug-handler.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Composer\XdebugHandler;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
/**
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
* @internal
*/
class Status
{
const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
const CHECK = 'Check';
const ERROR = 'Error';
const INFO = 'Info';
const NORESTART = 'NoRestart';
const RESTART = 'Restart';
const RESTARTING = 'Restarting';
const RESTARTED = 'Restarted';
/** @var bool */
private $debug;
/** @var string */
private $envAllowXdebug;
/** @var string|null */
private $loaded;
/** @var LoggerInterface|null */
private $logger;
/** @var bool */
private $modeOff;
/** @var float */
private $time;
/**
* @param string $envAllowXdebug Prefixed _ALLOW_XDEBUG name
* @param bool $debug Whether debug output is required
*/
public function __construct(string $envAllowXdebug, bool $debug)
{
$start = getenv(self::ENV_RESTART);
Process::setEnv(self::ENV_RESTART);
$this->time = is_numeric($start) ? round((microtime(true) - $start) * 1000) : 0;
$this->envAllowXdebug = $envAllowXdebug;
$this->debug = $debug && defined('STDERR');
$this->modeOff = false;
}
/**
* Activates status message output to a PSR3 logger
*
* @return void
*/
public function setLogger(LoggerInterface $logger): void
{
$this->logger = $logger;
}
/**
* Calls a handler method to report a message
*
* @throws \InvalidArgumentException If $op is not known
*/
public function report(string $op, ?string $data): void
{
if ($this->logger !== null || $this->debug) {
$param = (string) $data;
switch($op) {
case self::CHECK:
$this->reportCheck($param);
break;
case self::ERROR:
$this->reportError($param);
break;
case self::INFO:
$this->reportInfo($param);
break;
case self::NORESTART:
$this->reportNoRestart();
break;
case self::RESTART:
$this->reportRestart();
break;
case self::RESTARTED:
$this->reportRestarted();
break;
case self::RESTARTING:
$this->reportRestarting($param);
break;
default:
throw new \InvalidArgumentException('Unknown op handler: '.$op);
}
}
}
/**
* Outputs a status message
*/
private function output(string $text, ?string $level = null): void
{
if ($this->logger !== null) {
$this->logger->log($level !== null ? $level: LogLevel::DEBUG, $text);
}
if ($this->debug) {
fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
}
}
/**
* Checking status message
*/
private function reportCheck(string $loaded): void
{
list($version, $mode) = explode('|', $loaded);
if ($version !== '') {
$this->loaded = '('.$version.')'.($mode !== '' ? ' xdebug.mode='.$mode : '');
}
$this->modeOff = $mode === 'off';
$this->output('Checking '.$this->envAllowXdebug);
}
/**
* Error status message
*/
private function reportError(string $error): void
{
$this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
}
/**
* Info status message
*/
private function reportInfo(string $info): void
{
$this->output($info);
}
/**
* No restart status message
*/
private function reportNoRestart(): void
{
$this->output($this->getLoadedMessage());
if ($this->loaded !== null) {
$text = sprintf('No restart (%s)', $this->getEnvAllow());
if (!((bool) getenv($this->envAllowXdebug))) {
$text .= ' Allowed by '.($this->modeOff ? 'xdebug.mode' : 'application');
}
$this->output($text);
}
}
/**
* Restart status message
*/
private function reportRestart(): void
{
$this->output($this->getLoadedMessage());
Process::setEnv(self::ENV_RESTART, (string) microtime(true));
}
/**
* Restarted status message
*/
private function reportRestarted(): void
{
$loaded = $this->getLoadedMessage();
$text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
$level = $this->loaded !== null ? LogLevel::WARNING : null;
$this->output($text, $level);
}
/**
* Restarting status message
*/
private function reportRestarting(string $command): void
{
$text = sprintf('Process restarting (%s)', $this->getEnvAllow());
$this->output($text);
$text = 'Running: '.$command;
$this->output($text);
}
/**
* Returns the _ALLOW_XDEBUG environment variable as name=value
*/
private function getEnvAllow(): string
{
return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
}
/**
* Returns the Xdebug status and version
*/
private function getLoadedMessage(): string
{
$loaded = $this->loaded !== null ? sprintf('loaded %s', $this->loaded) : 'not loaded';
return 'The Xdebug extension is '.$loaded;
}
}

View File

@ -1,722 +0,0 @@
<?php
/*
* This file is part of composer/xdebug-handler.
*
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Composer\XdebugHandler;
use Composer\Pcre\Preg;
use Psr\Log\LoggerInterface;
/**
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
*
* @phpstan-import-type restartData from PhpConfig
*/
class XdebugHandler
{
const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
const SUFFIX_INIS = '_ORIGINAL_INIS';
const RESTART_ID = 'internal';
const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
const DEBUG = 'XDEBUG_HANDLER_DEBUG';
/** @var string|null */
protected $tmpIni;
/** @var bool */
private static $inRestart;
/** @var string */
private static $name;
/** @var string|null */
private static $skipped;
/** @var bool */
private static $xdebugActive;
/** @var string|null */
private static $xdebugMode;
/** @var string|null */
private static $xdebugVersion;
/** @var bool */
private $cli;
/** @var string|null */
private $debug;
/** @var string */
private $envAllowXdebug;
/** @var string */
private $envOriginalInis;
/** @var bool */
private $persistent;
/** @var string|null */
private $script;
/** @var Status */
private $statusWriter;
/**
* Constructor
*
* The $envPrefix is used to create distinct environment variables. It is
* uppercased and prepended to the default base values. For example 'myapp'
* would result in MYAPP_ALLOW_XDEBUG and MYAPP_ORIGINAL_INIS.
*
* @param string $envPrefix Value used in environment variables
* @throws \RuntimeException If the parameter is invalid
*/
public function __construct(string $envPrefix)
{
if ($envPrefix === '') {
throw new \RuntimeException('Invalid constructor parameter');
}
self::$name = strtoupper($envPrefix);
$this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
$this->envOriginalInis = self::$name.self::SUFFIX_INIS;
self::setXdebugDetails();
self::$inRestart = false;
if ($this->cli = PHP_SAPI === 'cli') {
$this->debug = (string) getenv(self::DEBUG);
}
$this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
}
/**
* Activates status message output to a PSR3 logger
*/
public function setLogger(LoggerInterface $logger): self
{
$this->statusWriter->setLogger($logger);
return $this;
}
/**
* Sets the main script location if it cannot be called from argv
*/
public function setMainScript(string $script): self
{
$this->script = $script;
return $this;
}
/**
* Persist the settings to keep Xdebug out of sub-processes
*/
public function setPersistent(): self
{
$this->persistent = true;
return $this;
}
/**
* Checks if Xdebug is loaded and the process needs to be restarted
*
* This behaviour can be disabled by setting the MYAPP_ALLOW_XDEBUG
* environment variable to 1. This variable is used internally so that
* the restarted process is created only once.
*/
public function check(): void
{
$this->notify(Status::CHECK, self::$xdebugVersion.'|'.self::$xdebugMode);
$envArgs = explode('|', (string) getenv($this->envAllowXdebug));
if (!((bool) $envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
// Restart required
$this->notify(Status::RESTART);
$command = $this->prepareRestart();
if ($command !== null) {
$this->restart($command);
}
return;
}
if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
// Restarted, so unset environment variable and use saved values
$this->notify(Status::RESTARTED);
Process::setEnv($this->envAllowXdebug);
self::$inRestart = true;
if (self::$xdebugVersion === null) {
// Skipped version is only set if Xdebug is not loaded
self::$skipped = $envArgs[1];
}
$this->tryEnableSignals();
// Put restart settings in the environment
$this->setEnvRestartSettings($envArgs);
return;
}
$this->notify(Status::NORESTART);
$settings = self::getRestartSettings();
if ($settings !== null) {
// Called with existing settings, so sync our settings
$this->syncSettings($settings);
}
}
/**
* Returns an array of php.ini locations with at least one entry
*
* The equivalent of calling php_ini_loaded_file then php_ini_scanned_files.
* The loaded ini location is the first entry and may be an empty string.
*
* @return non-empty-list<string>
*/
public static function getAllIniFiles(): array
{
if (self::$name !== null) {
$env = getenv(self::$name.self::SUFFIX_INIS);
if (false !== $env) {
return explode(PATH_SEPARATOR, $env);
}
}
$paths = [(string) php_ini_loaded_file()];
$scanned = php_ini_scanned_files();
if ($scanned !== false) {
$paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
}
return $paths;
}
/**
* Returns an array of restart settings or null
*
* Settings will be available if the current process was restarted, or
* called with the settings from an existing restart.
*
* @phpstan-return restartData|null
*/
public static function getRestartSettings(): ?array
{
$envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
if (count($envArgs) !== 6
|| (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
return null;
}
return [
'tmpIni' => $envArgs[0],
'scannedInis' => (bool) $envArgs[1],
'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
'skipped' => $envArgs[5],
];
}
/**
* Returns the Xdebug version that triggered a successful restart
*/
public static function getSkippedVersion(): string
{
return (string) self::$skipped;
}
/**
* Returns whether Xdebug is loaded and active
*
* true: if Xdebug is loaded and is running in an active mode.
* false: if Xdebug is not loaded, or it is running with xdebug.mode=off.
*/
public static function isXdebugActive(): bool
{
self::setXdebugDetails();
return self::$xdebugActive;
}
/**
* Allows an extending class to decide if there should be a restart
*
* The default is to restart if Xdebug is loaded and its mode is not "off".
*/
protected function requiresRestart(bool $default): bool
{
return $default;
}
/**
* Allows an extending class to access the tmpIni
*
* @param non-empty-list<string> $command
*/
protected function restart(array $command): void
{
$this->doRestart($command);
}
/**
* Executes the restarted command then deletes the tmp ini
*
* @param non-empty-list<string> $command
* @phpstan-return never
*/
private function doRestart(array $command): void
{
if (PHP_VERSION_ID >= 70400) {
$cmd = $command;
$displayCmd = sprintf('[%s]', implode(', ', $cmd));
} else {
$cmd = Process::escapeShellCommand($command);
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
// Outer quotes required on cmd string below PHP 8
$cmd = '"'.$cmd.'"';
}
$displayCmd = $cmd;
}
$this->tryEnableSignals();
$this->notify(Status::RESTARTING, $displayCmd);
$process = proc_open($cmd, [], $pipes);
if (is_resource($process)) {
$exitCode = proc_close($process);
}
if (!isset($exitCode)) {
// Unlikely that php or the default shell cannot be invoked
$this->notify(Status::ERROR, 'Unable to restart process');
$exitCode = -1;
} else {
$this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
}
if ($this->debug === '2') {
$this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
} else {
@unlink((string) $this->tmpIni);
}
exit($exitCode);
}
/**
* Returns the command line array if everything was written for the restart
*
* If any of the following fails (however unlikely) we must return false to
* stop potential recursion:
* - tmp ini file creation
* - environment variable creation
*
* @return non-empty-list<string>|null
*/
private function prepareRestart(): ?array
{
if (!$this->cli) {
$this->notify(Status::ERROR, 'Unsupported SAPI: '.PHP_SAPI);
return null;
}
if (($argv = $this->checkServerArgv()) === null) {
$this->notify(Status::ERROR, '$_SERVER[argv] is not as expected');
return null;
}
if (!$this->checkConfiguration($info)) {
$this->notify(Status::ERROR, $info);
return null;
}
$mainScript = (string) $this->script;
if (!$this->checkMainScript($mainScript, $argv)) {
$this->notify(Status::ERROR, 'Unable to access main script: '.$mainScript);
return null;
}
$tmpDir = sys_get_temp_dir();
$iniError = 'Unable to create temp ini file at: '.$tmpDir;
if (($tmpfile = @tempnam($tmpDir, '')) === false) {
$this->notify(Status::ERROR, $iniError);
return null;
}
$error = null;
$iniFiles = self::getAllIniFiles();
$scannedInis = count($iniFiles) > 1;
if (!$this->writeTmpIni($tmpfile, $iniFiles, $error)) {
$this->notify(Status::ERROR, $error ?? $iniError);
@unlink($tmpfile);
return null;
}
if (!$this->setEnvironment($scannedInis, $iniFiles, $tmpfile)) {
$this->notify(Status::ERROR, 'Unable to set environment variables');
@unlink($tmpfile);
return null;
}
$this->tmpIni = $tmpfile;
return $this->getCommand($argv, $tmpfile, $mainScript);
}
/**
* Returns true if the tmp ini file was written
*
* @param non-empty-list<string> $iniFiles All ini files used in the current process
*/
private function writeTmpIni(string $tmpFile, array $iniFiles, ?string &$error): bool
{
// $iniFiles has at least one item and it may be empty
if ($iniFiles[0] === '') {
array_shift($iniFiles);
}
$content = '';
$sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
$xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
foreach ($iniFiles as $file) {
// Check for inaccessible ini files
if (($data = @file_get_contents($file)) === false) {
$error = 'Unable to read ini: '.$file;
return false;
}
// Check and remove directives after HOST and PATH sections
if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches)) {
$data = substr($data, 0, $matches[0][1]);
}
$content .= Preg::replace($xdebugRegex, ';$1', $data).PHP_EOL;
}
// Merge loaded settings into our ini content, if it is valid
$config = parse_ini_string($content);
$loaded = ini_get_all(null, false);
if (false === $config || false === $loaded) {
$error = 'Unable to parse ini data';
return false;
}
$content .= $this->mergeLoadedConfig($loaded, $config);
// Work-around for https://bugs.php.net/bug.php?id=75932
$content .= 'opcache.enable_cli=0'.PHP_EOL;
return (bool) @file_put_contents($tmpFile, $content);
}
/**
* Returns the command line arguments for the restart
*
* @param non-empty-list<string> $argv
* @return non-empty-list<string>
*/
private function getCommand(array $argv, string $tmpIni, string $mainScript): array
{
$php = [PHP_BINARY];
$args = array_slice($argv, 1);
if (!$this->persistent) {
// Use command-line options
array_push($php, '-n', '-c', $tmpIni);
}
return array_merge($php, [$mainScript], $args);
}
/**
* Returns true if the restart environment variables were set
*
* No need to update $_SERVER since this is set in the restarted process.
*
* @param non-empty-list<string> $iniFiles All ini files used in the current process
*/
private function setEnvironment(bool $scannedInis, array $iniFiles, string $tmpIni): bool
{
$scanDir = getenv('PHP_INI_SCAN_DIR');
$phprc = getenv('PHPRC');
// Make original inis available to restarted process
if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
return false;
}
if ($this->persistent) {
// Use the environment to persist the settings
if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$tmpIni)) {
return false;
}
}
// Flag restarted process and save values for it to use
$envArgs = [
self::RESTART_ID,
self::$xdebugVersion,
(int) $scannedInis,
false === $scanDir ? '*' : $scanDir,
false === $phprc ? '*' : $phprc,
];
return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
}
/**
* Logs status messages
*/
private function notify(string $op, ?string $data = null): void
{
$this->statusWriter->report($op, $data);
}
/**
* Returns default, changed and command-line ini settings
*
* @param mixed[] $loadedConfig All current ini settings
* @param mixed[] $iniConfig Settings from user ini files
*
*/
private function mergeLoadedConfig(array $loadedConfig, array $iniConfig): string
{
$content = '';
foreach ($loadedConfig as $name => $value) {
// Value will either be null, string or array (HHVM only)
if (!is_string($value)
|| strpos($name, 'xdebug') === 0
|| $name === 'apc.mmap_file_mask') {
continue;
}
if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
// Double-quote escape each value
$content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
}
}
return $content;
}
/**
* Returns true if the script name can be used
*
* @param non-empty-list<string> $argv
*/
private function checkMainScript(string &$mainScript, array $argv): bool
{
if ($mainScript !== '') {
// Allow an application to set -- for standard input
return file_exists($mainScript) || '--' === $mainScript;
}
if (file_exists($mainScript = $argv[0])) {
return true;
}
// Use a backtrace to resolve Phar and chdir issues.
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$main = end($trace);
if ($main !== false && isset($main['file'])) {
return file_exists($mainScript = $main['file']);
}
return false;
}
/**
* Adds restart settings to the environment
*
* @param non-empty-list<string> $envArgs
*/
private function setEnvRestartSettings(array $envArgs): void
{
$settings = [
php_ini_loaded_file(),
$envArgs[2],
$envArgs[3],
$envArgs[4],
getenv($this->envOriginalInis),
self::$skipped,
];
Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
}
/**
* Syncs settings and the environment if called with existing settings
*
* @phpstan-param restartData $settings
*/
private function syncSettings(array $settings): void
{
if (false === getenv($this->envOriginalInis)) {
// Called by another app, so make original inis available
Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
}
self::$skipped = $settings['skipped'];
$this->notify(Status::INFO, 'Process called with existing restart settings');
}
/**
* Returns true if there are no known configuration issues
*/
private function checkConfiguration(?string &$info): bool
{
if (!function_exists('proc_open')) {
$info = 'proc_open function is disabled';
return false;
}
if (!file_exists(PHP_BINARY)) {
$info = 'PHP_BINARY is not available';
return false;
}
if (extension_loaded('uopz') && !((bool) ini_get('uopz.disable'))) {
// uopz works at opcode level and disables exit calls
if (function_exists('uopz_allow_exit')) {
@uopz_allow_exit(true);
} else {
$info = 'uopz extension is not compatible';
return false;
}
}
// Check UNC paths when using cmd.exe
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
$workingDir = getcwd();
if ($workingDir === false) {
$info = 'unable to determine working directory';
return false;
}
if (0 === strpos($workingDir, '\\\\')) {
$info = 'cmd.exe does not support UNC paths: '.$workingDir;
return false;
}
}
return true;
}
/**
* Enables async signals and control interrupts in the restarted process
*
* Available on Unix PHP 7.1+ with the pcntl extension and Windows PHP 7.4+.
*/
private function tryEnableSignals(): void
{
if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
pcntl_async_signals(true);
$message = 'Async signals enabled';
if (!self::$inRestart) {
// Restarting, so ignore SIGINT in parent
pcntl_signal(SIGINT, SIG_IGN);
} elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
// Restarted, no handler set so force default action
pcntl_signal(SIGINT, SIG_DFL);
}
}
if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
// Restarting, so set a handler to ignore CTRL events in the parent.
// This ensures that CTRL+C events will be available in the child
// process without having to enable them there, which is unreliable.
sapi_windows_set_ctrl_handler(function ($evt) {});
}
}
/**
* Returns $_SERVER['argv'] if it is as expected
*
* @return non-empty-list<string>|null
*/
private function checkServerArgv(): ?array
{
$result = [];
if (isset($_SERVER['argv']) && is_array($_SERVER['argv'])) {
foreach ($_SERVER['argv'] as $value) {
if (!is_string($value)) {
return null;
}
$result[] = $value;
}
}
return count($result) > 0 ? $result : null;
}
/**
* Sets static properties $xdebugActive, $xdebugVersion and $xdebugMode
*/
private static function setXdebugDetails(): void
{
if (self::$xdebugActive !== null) {
return;
}
self::$xdebugActive = false;
if (!extension_loaded('xdebug')) {
return;
}
$version = phpversion('xdebug');
self::$xdebugVersion = $version !== false ? $version : 'unknown';
if (version_compare(self::$xdebugVersion, '3.1', '>=')) {
$modes = xdebug_info('mode');
self::$xdebugMode = count($modes) === 0 ? 'off' : implode(',', $modes);
self::$xdebugActive = self::$xdebugMode !== 'off';
return;
}
// See if xdebug.mode is supported in this version
$iniMode = ini_get('xdebug.mode');
if ($iniMode === false) {
self::$xdebugActive = true;
return;
}
// Environment value wins but cannot be empty
$envMode = (string) getenv('XDEBUG_MODE');
if ($envMode !== '') {
self::$xdebugMode = $envMode;
} else {
self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
}
// An empty comma-separated list is treated as mode 'off'
if (Preg::isMatch('/^,+$/', str_replace(' ', '', self::$xdebugMode))) {
self::$xdebugMode = 'off';
}
self::$xdebugActive = self::$xdebugMode !== 'off';
}
}

View File

@ -1,199 +0,0 @@
# CHANGELOG
## [Unreleased](https://github.com/FakerPHP/Faker/compare/v1.23.1...1.23)
## [2023-09-29, v1.23.1](https://github.com/FakerPHP/Faker/compare/v1.23.0..v1.23.1)
- Fixed double `а` female lastName in `ru_RU/Person::name()` (#832)
- Fixed polish license plates (#685)
- Stopped using `static` in callables in `Provider\pt_BR\PhoneNumber` (#785)
- Fixed incorrect female name (#794)
- Stopped using the deprecated `MT_RAND_PHP` constant to seed the random generator on PHP 8.3 (#844)
## [2023-06-12, v1.23.0](https://github.com/FakerPHP/Faker/compare/v1.22.0..v1.23.0)
- Update `randomElements` to return random number of elements when no count is provided (#658)
## [2023-05-14, v1.22.0](https://github.com/FakerPHP/Faker/compare/v1.21.0..v1.22.0)
- Fixed `randomElements()` to accept empty iterator (#605)
- Added support for passing an `Enum` to `randomElement()` and `randomElements()` (#620)
- Started rejecting invalid arguments passed to `randomElement()` and `randomElements()` (#642)
## [2022-12-13, v1.21.0](https://github.com/FakerPHP/Faker/compare/v1.20.0..v1.21.0)
- Dropped support for PHP 7.1, 7.2, and 7.3 (#543)
- Added support for PHP 8.2 (#528)
## [2022-07-20, v1.20.0](https://github.com/FakerPHP/Faker/compare/v1.19.0..v1.20.0)
- Fixed typo in French phone number (#452)
- Fixed some Hungarian naming bugs (#451)
- Fixed bug where the NL-BE VAT generation was incorrect (#455)
- Improve Turkish phone numbers for E164 and added landline support (#460)
- Add Microsoft Edge User Agent (#464)
- Added option to set image formats on Faker\Provider\Image (#473)
- Added support for French color translations (#466)
- Support filtering timezones by country code (#480)
- Fixed typo in some greek names (#490)
- Marked the Faker\Provider\Image as deprecated
## [2022-02-02, v1.19.0](https://github.com/FakerPHP/Faker/compare/v1.18.0..v1.19.0)
- Added color extension to core (#442)
- Added conflict with `doctrine/persistence` below version `1.4`
- Fix for support on different Doctrine ORM versions (#414)
- Fix usage of `Doctrine\Persistence` dependency
- Fix CZ Person birthNumber docblock return type (#437)
- Fix is_IS Person docbock types (#439)
- Fix is_IS Address docbock type (#438)
- Fix regexify escape backslash in character class (#434)
- Removed UUID from Generator to be able to extend it (#441)
## [2022-01-23, v1.18.0](https://github.com/FakerPHP/Faker/compare/v1.17.0..v1.18.0)
- Deprecated UUID, use uuid3 to specify version (#427)
- Reset formatters when adding a new provider (#366)
- Helper methods to use our custom generators (#155)
- Set allow-plugins for Composer 2.2 (#405)
- Fix kk_KZ\Person::individualIdentificationNumber generation (#411)
- Allow for -> syntax to be used in parsing (#423)
- Person->name was missing string return type (#424)
- Generate a valid BE TAX number (#415)
- Added the UUID extension to Core (#427)
## [2021-12-05, v1.17.0](https://github.com/FakerPHP/Faker/compare/v1.16.0..v1.17.0)
- Partial PHP 8.1 compatibility (#373)
- Add payment provider for `ne_NP` locale (#375)
- Add Egyptian Arabic `ar_EG` locale (#377)
- Updated list of South African TLDs (#383)
- Fixed formatting of E.164 numbers (#380)
- Allow `symfony/deprecation-contracts` `^3.0` (#397)
## [2021-09-06, v1.16.0](https://github.com/FakerPHP/Faker/compare/v1.15.0..v1.16.0)
- Add Company extension
- Add Address extension
- Add Person extension
- Add PhoneNumber extension
- Add VersionExtension (#350)
- Stricter types in Extension\Container and Extension\GeneratorAwareExtension (#345)
- Fix deprecated property access in `nl_NL` (#348)
- Add support for `psr/container` >= 2.0 (#354)
- Add missing union types in Faker\Generator (#352)
## [2021-07-06, v1.15.0](https://github.com/FakerPHP/Faker/compare/v1.14.1..v1.15.0)
- Updated the generator phpdoc to help identify magic methods (#307)
- Prevent direct access and triggered deprecation warning for "word" (#302)
- Updated length on all global e164 numbers (#301)
- Updated last names from different source (#312)
- Don't generate birth number of '000' for Swedish personal identity (#306)
- Add job list for localization id_ID (#339)
## [2021-03-30, v1.14.1](https://github.com/FakerPHP/Faker/compare/v1.14.0..v1.14.1)
- Fix where randomNumber and randomFloat would return a 0 value (#291 / #292)
## [2021-03-29, v1.14.0](https://github.com/FakerPHP/Faker/compare/v1.13.0..v1.14.0)
- Fix for realText to ensure the text keeps closer to its boundaries (#152)
- Fix where regexify produces a random character instead of a literal dot (#135
- Deprecate zh_TW methods that only call base methods (#122)
- Add used extensions to composer.json as suggestion (#120)
- Moved TCNo and INN from calculator to localized providers (#108)
- Fix regex dot/backslash issue where a dot is replaced with a backslash as escape character (#206)
- Deprecate direct property access (#164)
- Added test to assert unique() behaviour (#233)
- Added RUC for the es_PE locale (#244)
- Test IBAN formats for Latin America (AR/PE/VE) (#260)
- Added VAT number for en_GB (#255)
- Added new districts for the ne_NP locale (#258)
- Fix for U.S. Area Code Generation (#261)
- Fix in numerify where a better random numeric value is guaranteed (#256)
- Fix e164PhoneNumber to only generate valid phone numbers with valid country codes (#264)
- Extract fixtures into separate classes (#234)
- Remove french domains that no longer exists (#277)
- Fix error that occurs when getting a polish title (#279)
- Use valid area codes for North America E164 phone numbers (#280)
- Adding support for extensions and PSR-11 (#154)
- Adding trait for GeneratorAwareExtension (#165)
- Added helper class for extension (#162)
- Added blood extension to core (#232)
- Added barcode extension to core (#252)
- Added number extension (#257)
- Various code style updates
- Added a note about our breaking change promise (#273)
## [2020-12-18, v1.13.0](https://github.com/FakerPHP/Faker/compare/v1.12.1..v1.13.0)
Several fixes and new additions in this release. A lot of cleanup has been done
on the codebase on both tests and consistency.
- Feature/pl pl license plate (#62)
- Fix greek phone numbers (#16)
- Move AT payment provider logic to de_AT (#72)
- Fix wiktionary links (#73)
- Fix AT person links (#74)
- Fix AT cities (#75)
- Deprecate at_AT providers (#78)
- Add Austrian `ssn()` to `Person` provider (#79)
- Fix typos in id_ID Address (#83)
- Austrian post codes (#86)
- Updated Polish data (#70)
- Improve Austrian social security number generation (#88)
- Move US phone numbers with extension to own method (#91)
- Add UK National Insurance number generator (#89)
- Fix en_SG phone number generator (#100)
- Remove usage of mt_rand (#87)
- Remove whitespace from beginning of el_GR phone numbers (#105)
- Building numbers can not be 0, 00, 000 (#107)
- Add 172.16/12 local IPv4 block (#121)
- Add JCB credit card type (#124)
- Remove json_decode from emoji generation (#123)
- Remove ro street address (#146)
## [2020-12-11, v1.12.1](https://github.com/FakerPHP/Faker/compare/v1.12.0..v1.12.1)
This is a security release that prevents a hacker to execute code on the server.
## [2020-11-23, v1.12.0](https://github.com/FakerPHP/Faker/compare/v1.11.0..v1.12.0)
- Fix ro_RO first and last day of year calculation offset (#65)
- Fix en_NG locale test namespaces that did not match PSR-4 (#57)
- Added Singapore NRIC/FIN provider (#56)
- Added provider for Lithuanian municipalities (#58)
- Added blood types provider (#61)
## [2020-11-15, v1.11.0](https://github.com/FakerPHP/Faker/compare/v1.10.1..v1.11.0)
- Added Provider for Swedish Municipalities
- Updates to person names in pt_BR
- Many code style changes
## [2020-10-28, v1.10.1](https://github.com/FakerPHP/Faker/compare/v1.10.0..v1.10.1)
- Updates the Danish addresses in dk_DK
- Removed offense company names in nl_NL
- Clarify changelog with original fork
- Standin replacement for LoremPixel to Placeholder.com (#11)
## [2020-10-27, v1.10.0](https://github.com/FakerPHP/Faker/compare/v1.9.1..v1.10.0)
- Support PHP 7.1-8.0
- Fix typo in de_DE Company Provider
- Fix dateTimeThisYear method
- Fix typo in de_DE jobTitleFormat
- Fix IBAN generation for CR
- Fix typos in greek first names
- Fix US job title typo
- Do not clear entity manager for doctrine orm populator
- Remove persian rude words
- Corrections to RU names
## 2020-10-27, v1.9.1
- Initial version. Same as `fzaninotto/Faker:v1.9.1`.

Some files were not shown because too many files have changed in this diff Show More