Location: PHPKode > projects > NOLA > admininvattachupd.php
<? include('includes/main.php'); ?>
<script language="JavaScript">
      var calDateFormat='yyyy-MM-DD';
</script>
<script language="JavaScript" src="js/calendar.js"></script>
<? //admininvattachupd.php - copyright 2001 by Noguska - Fostoria, OH
     echo texttitle(STR_INVENTORY_FILE_ATTACHMENT_MAINTAINENCE);
     if ($itemcode||$begindate||$enddate) {
	  $count=0;
	  $begindate=strtotime($begindate);
	  $enddate=strtotime($enddate);
          if ($itemcode) {
                 $recordSet = &$conn->Execute("select id from item where item.companyid=".$active_company." and item.itemcode=".sqlprep($itemcode));
                 if (!$recordSet->EOF) $itemid=$recordSet->fields[0];
          };
          checkpermissions('inv');
          if ($dir = @opendir(IMAGE_UPLOAD_DIR)) {
                 while($file = readdir($dir)) {
			if ($begindate||$enddate) {
				$ctime=filectime(IMAGE_UPLOAD_DIR.$file); //get file modified time
	            if (substr_count($file, "graphic")==1) {
					if ($ctime>$begindate&&$ctime<$enddate) {
						unlink(IMAGE_UPLOAD_DIR.$file);
						$count++;
					};
				};
	            if (substr_count($file, "catalog")==1) {
					if ($ctime>$begindate&&$ctime<$enddate) {
						unlink(IMAGE_UPLOAD_DIR.$file);
						$count++;
					};
				};
			};
			if ($itemcode) {
		            if (substr_count($file, "graphic".$itemid.".")==1) {
						unlink(IMAGE_UPLOAD_DIR.$file);
						$count++;
					};
		            if (substr_count($file, "catalog".$itemid.".")==1) {
						unlink(IMAGE_UPLOAD_DIR.$file);
						$count++;
					};
			};
		 };
         closedir($dir);
	  	 echo textsuccess($count.' '.STR_FILES_REMOVED);
      };
     };
     $timestamp =  time();
     $date_time_array =  getdate($timestamp);
     $hours = $date_time_array["hours"];
     $minutes = $date_time_array["minutes"];
     $seconds = $date_time_array["seconds"];
     $month = $date_time_array["mon"];
     $day = $date_time_array["mday"];
     $year = $date_time_array["year"];
     $timestamp = mktime($hour, $minute, $second, $month-6, $day, $year);
     $sixmo=date("Y-m-d", $timestamp);
     echo '<form action="admininvattachupd.php" method="post" name="mainform"><table>';
     echo '<tr><th colspan="2" align="center"> '.STR_SELECT_ITEM_OR_DATE_RANGE_TO_PURGE.':</td></tr>';
     echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">'.STR_ITEM_CODE.':</td><td><input type="text" name="itemcode" size="30" maxlength="20"'.INC_TEXTBOX.'><a href="javascript:doNothing()" onclick="top.newWin = window.open(\'lookupitem.php?name=itemcode\',\'cal\',\'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes\')"><img src="'.IMAGE_ITEM_LOOKUP.'" border="0" alt="Item Lookup"></a></td></tr>';
     echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">'.STR_BEGIN_DATE.': </td><td><input type="text" name="begindate" size="10" value="0000-00-00"'.INC_TEXTBOX.'><a href="javascript:doNothing()" onclick="setDateField(document.mainform.begindate); top.newWin = window.open(\'calendar.html\',\'cal\',\'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes\')"><img src="'.IMAGE_DATE_LOOKUP.'" border="0" alt="Display Calendar"></a></td></tr>';
     echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">'.STR_END_DATE.': </td><td><input type="text" name="enddate" size="10" value="'.$sixmo.'"'.INC_TEXTBOX.' checked><a href="javascript:doNothing()" onclick="setDateField(document.mainform.enddate); top.newWin = window.open(\'calendar.html\',\'cal\',\'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes\')"><img src="'.IMAGE_DATE_LOOKUP.'" border="0" alt="Display Calendar"></a></td></tr>';
     echo '</table><input type="submit" value="'.STR_REMOVE_FILES.'"></form>';
?>
<? include('includes/footer.php'); ?>
Return current item: NOLA