Skip to content

Commit

Permalink
Update: popup code pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
idoalit committed Jun 23, 2016
1 parent 7f06a17 commit 1138e80
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
9 changes: 7 additions & 2 deletions admin/modules/bibliography/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,14 @@ function getimagesizefromstring($string_data)
$form->addTextField('textarea', 'specDetailInfo', __('Specific Detail Info'), $rec_d['spec_detail_info'], 'rows="2" style="width: 100%"', __('explain more details about an item e.g. scale within a map, running time in a movie dvd.'));
// biblio item batch add (by.ido alit)
$pattern_options = array(
// default value
array($sysconf['batch_item_code_pattern'], $sysconf['batch_item_code_pattern'])
);
// get pattern from database
$pattern_q = $dbs->query('SELECT setting_value FROM setting WHERE setting_name = \'batch_item_code_pattern\'');
if (!$dbs->errno) {
// empty pattern
$pattern_options = array();
$pattern_d = $pattern_q->fetch_row();
$val = @unserialize($pattern_d[0]);
if (!empty($val)) {
Expand All @@ -559,8 +562,8 @@ function getimagesizefromstring($string_data)
}
}
}
$str_input = '<a class="notAJAX btn btn-primary openPopUp" href="'.MWB.'bibliography/pop_pattern.php" title="'.__('Add new pattern').'"><i class="glyphicon glyphicon-plus"></i> Add New Pattern</a>&nbsp;';
$str_input .= simbio_form_element::selectList('itemCodePattern', $pattern_options, '', 'style="width: 120px;"').' &nbsp;';
$str_input = '<a class="notAJAX btn btn-primary openPopUp notIframe" href="'.MWB.'bibliography/pop_pattern.php" height="420px" title="'.__('Add new pattern').'"><i class="glyphicon glyphicon-plus"></i> Add New Pattern</a>&nbsp;';
$str_input .= simbio_form_element::selectList('itemCodePattern', $pattern_options, '', 'style="width: auto"').' &nbsp;';
$str_input .= __('Total item(s)').': <input type="text" class="small_input" style="width: 100px;" name="totalItems" value="0" /> &nbsp;';
// get collection type data related to this record from database
$coll_type_q = $dbs->query("SELECT coll_type_id, coll_type_name FROM mst_coll_type");
Expand Down Expand Up @@ -791,6 +794,8 @@ function getimagesizefromstring($string_data)
$('#class').change(function() {
$('#callNumber').val($(this).val().replace('NEW:',''));
});

// popup pattern
});
</script>
<?php
Expand Down
40 changes: 30 additions & 10 deletions admin/modules/bibliography/pop_pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
if (!$can_write) {
die('<div class="errorBox">'.__('You are not authorized to view this section').'</div>');
}

$succces_msg = 'Pattern Saved!';
$failed_msg = 'Pattern Saved Failed!';
if (isset($_POST['saveData'])) {
$prefix = trim($dbs->escape_string(strip_tags($_POST['prefix'])));
$suffix = trim($dbs->escape_string(strip_tags($_POST['suffix'])));
$length_serial = trim($dbs->escape_string(strip_tags($_POST['length_serial'])));

if ($length_serial <= 3) {
if ($length_serial <= 2) {
utility::jsAlert('Please, fill length serial number more than 2');
} else {
// get database setting
Expand All @@ -63,32 +64,32 @@
// update
$update = $dbs->query('UPDATE setting SET setting_value=\''.$data_serialize.'\' WHERE setting_name=\'batch_item_code_pattern\'');
if ($update) {
utility::jsAlert('Pattern Saved');
echo $succces_msg;
} else {
utility::jsAlert('Pattern Saved Failed!');
echo $failed_msg;
}
} else {
$data_serialize = serialize($patterns);
// insert
$insert = $dbs->query("INSERT INTO setting(setting_name, setting_value) VALUES ('batch_item_code_pattern','$data_serialize')");
if ($insert) {
utility::jsAlert('Pattern Saved');
echo $succces_msg;
} else {
utility::jsAlert('Pattern Saved Failed!');
echo $failed_msg;
}
}
} else {
$data_serialize = serialize($patterns);
// insert
$insert = $dbs->query("INSERT INTO setting(setting_name, setting_value) VALUES ('batch_item_code_pattern','$data_serialize')");
if ($insert) {
utility::jsAlert('Pattern Saved');
echo $succces_msg;
} else {
utility::jsAlert('Pattern Saved Failed!');
echo $failed_msg;
}
}
}
// exit();
exit();
}

// page title
Expand All @@ -113,11 +114,15 @@
// length serial number
$form->addTextField('text', 'length_serial', __('Length serial number'), '5', 'style="width: 60%;"');

$form->addHidden('saveData', 'save');

// print out the object
echo '<div style="padding:20px;">';
echo $form->printOut();

// preview patternt
echo '<hr><h4>Preview: <b id="preview">P00000S</b></h4><hr>';
echo '</div>';

?>
<script type="text/javascript">
Expand All @@ -133,8 +138,23 @@
}
$('#preview').text(prefix + zeros + suffix);
});
$('#mainFormPattern').submit(function (e) {
var uri = '<?php echo $_SERVER['PHP_SELF']; ?>';
$.ajax({
url: uri,
type: 'post',
data: $( this ).serialize()
}).done(function (msg) {
alert(msg);
var pattern = $('#preview').text();
$('#itemCodePattern').append('<option value="'+ pattern +'">'+ pattern +'</option>');
jQuery.colorbox.close();
});
event.preventDefault();
});
</script>
<?php
$content = ob_get_clean();
echo $content;
// include the page template
require SB.'/admin/'.$sysconf['admin_template']['dir'].'/notemplate_page_tpl.php';
//require SB.'/admin/'.$sysconf['admin_template']['dir'].'/notemplate_page_tpl.php';

0 comments on commit 1138e80

Please sign in to comment.