added options to advanced search to pick attachment types

This commit is contained in:
SJ 2013-08-02 15:50:15 +02:00
parent 16e54ffbfd
commit a35ef4be57
4 changed files with 32 additions and 4 deletions

View File

@ -261,7 +261,7 @@ class ModelSearchSearch extends Model {
if($match) { $match .= " & "; } $match .= "(@subject " . $data['subject'] . ") ";
}
if($data['attachment_type'] && $data['attachment_type'] != "any") { if($match) { $match .= " & "; } $match .= "(@attachment_types " . $data['attachment_type'] . ") "; }
if($data['attachment_type'] && !strstr($data['attachment_type'], "any")) { if($match) { $match .= " & "; } $match .= "(@attachment_types " . preg_replace("/\,/", "|", $data['attachment_type']) . ") "; }
if($data['any']) {
@ -287,7 +287,7 @@ class ModelSearchSearch extends Model {
if(preg_match("/^(\>|\<)\={0,}\d{1,}$/", $data['size'])) { $size = "size " . $data['size'] . " AND "; }
}
if(isset($data['attachment_type']) && $data['attachment_type'] == 'any') { $a = "attachments > 0 AND "; }
if(isset($data['attachment_type']) && strstr($data['attachment_type'], 'any')) { $a = "attachments > 0 AND "; }
else if(isset($data['has_attachment']) && $data['has_attachment'] == 1) { $attachment = "attachments > 0 AND "; }

View File

@ -559,6 +559,16 @@ var Piler =
Piler.assemble_folder_restrictions();
var attachments_type = '';
if($('input#xhas_attachment_any', z)[0].checked) { attachments_type += ',any'; }
if($('input#xhas_attachment_doc', z)[0].checked) { attachments_type += ',word'; }
if($('input#xhas_attachment_xls', z)[0].checked) { attachments_type += ',excel'; }
if($('input#xhas_attachment_pdf', z)[0].checked) { attachments_type += ',pdf'; }
if($('input#xhas_attachment_image', z)[0].checked) { attachments_type += ',image'; }
if(attachments_type) { attachments_type = attachments_type.substring(1, attachments_type.length); }
Piler.Searches.Complex = {
from : $.trim($('input#xfrom', z).val()),
to : $.trim($('input#xto', z).val()),
@ -566,7 +576,7 @@ var Piler =
body : $.trim($('input#xbody', z).val()),
tag : $.trim($('input#xtag', z).val()),
note : $.trim($('input#xnote', z).val()),
attachment_type : $('input#xhas_attachment', z)[0].checked ? 'any' : '',
attachment_type : attachments_type,
date1 : $.trim($('input#date1', z).val()),
date2 : $.trim($('input#date2', z).val()),
searchtype : 'simple',

View File

@ -59,6 +59,18 @@
</div>
</div>
<div class="control-group">
<label class="control-label" for="xhas_attachment"><?php print $text_attachment; ?>:</label>
<div class="controls">
<img src="view/theme/default/assets/images/fileicons/doc.png" alt="Word" title="Word" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_doc" id="xhas_attachment_doc" <?php if(isset($has_attachment_doc) && $has_attachment_doc == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/default/assets/images/fileicons/xls.png" alt="Excel" title="Excel" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_xls" id="xhas_attachment_xls" <?php if(isset($has_attachment_xls) && $has_attachment_xls == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/default/assets/images/fileicons/pdf.png" alt="PDF" title=PDF"" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_pdf" id="xhas_attachment_pdf" <?php if(isset($has_attachment_pdf) && $has_attachment_pdf == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/default/assets/images/fileicons/image.png" alt="image" title="image" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_image" id="xhas_attachment_image" <?php if(isset($has_attachment_image) && $has_attachment_image == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/default/assets/images/fileicons/file.png" alt="any" title="any" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_any" id="xhas_attachment_any" <?php if(isset($has_attachment_any) && $has_attachment_any == 1) { ?>checked="checked"<?php } ?> />
</div>
</div>
<div class="control-group">
<label class="control-label" for="date1"><?php print $text_from; ?> <?php print $text_date; ?>:</label>
<div class="controls">

View File

@ -47,7 +47,13 @@
<div class="row">
<div class="cell1"><?php print $text_attachment; ?>:</div>
<div class="cell2 left"><input type="checkbox" class="checkbox popup" name="xhas_attachment" id="xhas_attachment" <?php if(isset($has_attachment) && $has_attachment == 1) { ?>checked="checked"<?php } ?> /></div>
<div class="cell2 left">
<img src="view/theme/mobile/images/fileicons/doc.png" alt="Word" title="Word" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_doc" id="xhas_attachment_doc" <?php if(isset($has_attachment_doc) && $has_attachment_doc == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/mobile/images/fileicons/xls.png" alt="Excel" title="Excel" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_xls" id="xhas_attachment_xls" <?php if(isset($has_attachment_xls) && $has_attachment_xls == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/mobile/images/fileicons/pdf.png" alt="PDF" title=PDF"" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_pdf" id="xhas_attachment_pdf" <?php if(isset($has_attachment_pdf) && $has_attachment_pdf == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/mobile/images/fileicons/image.png" alt="image" title="image" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_image" id="xhas_attachment_image" <?php if(isset($has_attachment_image) && $has_attachment_image == 1) { ?>checked="checked"<?php } ?> />
<img src="view/theme/mobile/images/fileicons/file.png" alt="any" title="any" /> <input type="checkbox" class="checkbox popup" name="xhas_attachment_any" id="xhas_attachment_any" <?php if(isset($has_attachment_any) && $has_attachment_any == 1) { ?>checked="checked"<?php } ?> />
</div>
</div>
<div class="row">