2024-07-10 12:43:19 +00:00
|
|
|
<?php
|
|
|
|
function cow($text = "")
|
|
|
|
{
|
|
|
|
echo ($text != "") ? $text : "COW";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
function createButton($name, $display, $id, $type = "Submit", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<div class="form-group">
|
|
|
|
<?php if ($type == "Submit") : ?>
|
|
|
|
<button type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>">
|
|
|
|
<?php echo function_exists("myLang") ? myLang($display) : $display; ?>
|
|
|
|
</button>
|
|
|
|
<?php else : ?>
|
|
|
|
<a href="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>">
|
|
|
|
<?php echo function_exists("myLang") ? myLang($display) : $display; ?>
|
|
|
|
</a>
|
|
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function createInput($name, $display, $id, $default = "", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
|
|
|
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>" placeholder="Enter <?php echo function_exists("myLang") ? myLang($display) : $display; ?>" value="<?php echo $default; ?>" autocomplete="off">
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function createDateInput($name, $display, $id, $default = "", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<label for="datepicker<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
|
|
|
<div class="input-group date datepickers" id="ass_date" data-target-input="nearest">
|
|
|
|
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" data-target="#<?php echo $id; ?>" data-toggle="datetimepicker" class="form-control datetimepicker <?php echo $class; ?>" autocomplete="off" required>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function createNepaliDateInput($name, $display, $id, $default = "", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<?php if ($display != "") : ?>
|
|
|
|
<label for="datepicker<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
|
|
|
<?php endif; ?>
|
|
|
|
<div class="input-group" id="ass_date" data-target-input="nearest">
|
|
|
|
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" class="form-control nepaliDatePicker <?php echo $class; ?>" autocomplete="off" value="<?php echo ($default == "") ? NepaliDate() : $default; ?>">
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function createSelect($name, $display, $values = array(), $id = "", $default = "", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
|
|
|
<select name="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" id="">
|
|
|
|
<option value="">Select <?php echo function_exists("myLang") ? myLang($display) : $display; ?></option>
|
|
|
|
<?php foreach ($values as $value) : ?>
|
|
|
|
<option value="<?php echo $value[0]; ?>"><?php echo $value[1]; ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function createTextarea($name, $display, $id, $default = "", $class = "")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
|
|
|
<textarea class="form-control <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" rows="3" placeholder="Enter <?php echo function_exists("myLang") ? myLang($display) : $display; ?>"><?php echo $default; ?></textarea>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function getNamesfromCSV($tableName, $fieldName, $lookupField, $referenceValue)
|
|
|
|
{
|
|
|
|
$ci = &get_instance();
|
|
|
|
$referenceValue = explode(",", $referenceValue);
|
|
|
|
$result = array();
|
|
|
|
foreach ($referenceValue as $V) :
|
|
|
|
$v = $ci->db->query("select $fieldName from $tableName where $lookupField='$V'")->row();
|
|
|
|
$result[] = $v->$fieldName;
|
|
|
|
endforeach;
|
|
|
|
return implode(",", $result);
|
|
|
|
}
|
|
|
|
function getFieldfromValue($tableName, $fieldName, $lookupField, $referenceValue)
|
|
|
|
{
|
|
|
|
$ci = &get_instance();
|
|
|
|
$t = "select $fieldName from $tableName where $lookupField='$referenceValue'"; //echo $t; //die;
|
|
|
|
$v = $ci->db->query($t);
|
|
|
|
if ($v->num_rows() > 0) {
|
|
|
|
$v = $v->row();
|
|
|
|
return $v->$fieldName;
|
|
|
|
} else {
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function fillComboWithValue($fieldName, $displayName, $fieldID, $tableName, $displayField, $valueField, $default = "", $CSSclass = "", $multiple = false, $condition = "")
|
|
|
|
{
|
|
|
|
$ci = &get_instance();
|
|
|
|
?>
|
|
|
|
<?php if ($displayName != "") : ?>
|
|
|
|
<label for="<?php echo $fieldID; ?>"><?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></label>
|
|
|
|
<?php endif; ?>
|
|
|
|
<select name="<?php echo $fieldName; ?><?php echo ($multiple) ? "[]" : ""; ?>" <?php if ($CSSclass != "none") : ?>class="form-control select2 <?php echo $CSSclass; ?>" <?php else : ?> class="form-control" <?php endif; ?> id="<?php echo $fieldID; ?>" <?php echo ($multiple) ? "multiple" : ""; ?>>
|
|
|
|
<option value="">Select <?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></option>
|
|
|
|
<?php
|
|
|
|
$q = "select * from $tableName";
|
|
|
|
$q .= ($condition != "") ? " where $condition" : " where status=1";
|
|
|
|
$Values = $ci->db->query($q)->result(); ?>
|
|
|
|
<?php foreach ($Values as $value) : ?>
|
|
|
|
<option value="<?php echo $value->$valueField; ?>" <?php echo ($value->$valueField == $default) ? 'SELECTED' : ''; ?>><?php echo $value->$displayField; ?></option>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</select>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function getTableSchema($tableName)
|
|
|
|
{
|
|
|
|
echo "<pre>";
|
|
|
|
//$R=DB::select("list columns from $tableName");
|
|
|
|
// print_r(Schema::getColumnListing($tableName));
|
|
|
|
echo "</pre>";
|
|
|
|
}
|
|
|
|
|
2024-07-22 12:16:09 +00:00
|
|
|
function showEditButton($url, $text = "Edit", $showtext="")
|
2024-07-10 12:43:19 +00:00
|
|
|
{
|
|
|
|
?>
|
2024-07-22 12:16:09 +00:00
|
|
|
<a href="<?php echo site_url($url); ?>" class="btn btn-info btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-edit"></i> <?php echo myLang($showtext);
|
2024-07-10 12:43:19 +00:00
|
|
|
?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function showDeleteButton($id, $text = "Delete")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-trash"></i> <?php //echo myLang($text);
|
|
|
|
?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function showListButton($url, $text = "List")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<a href="<?php echo site_url($url); ?>" class="btn btn-success btn-xs float-right" title="<?php echo myLang($text); ?>"><i class="fas fa-list"></i> <?php //echo myLang($text);
|
|
|
|
?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function showCreateButton($url, $text = "Create")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<a href="<?php echo site_url($url); ?>" class="btn btn-primary btn-xs float-right" title="<?php echo myLang($text); ?>"><i class="fas fa-pen"></i> <?php //echo myLang($text);
|
|
|
|
?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
function showDetailsButton($url, $text = "Details")
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<a href="<?php echo site_url($url); ?>" class="btn btn-primary btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-glasses"></i> <?php //echo myLang($text);
|
|
|
|
?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|