Commits

Jittat Fakcharoenphol committed 7d162ae

saves all company letter config

Comments (0)

Files changed (4)

regis/company/views.py

     
     company = Company.objects.get(id=company_id)
     config_letter = ConfigLetter.objects.filter(company=company_id,year=year_no)
+
+    if config_letter:
+        config_letter = config_letter[0]
+
+    if config_letter and config_letter.signer_name!='':
+        signer_name = config_letter.signer_name
+    else:
+        signer_name = u'ผู้จัดการแผนกทรัพยากรมนุษย์' + " " + company.name
+        if company.signer_name and company.signer_name != '':
+            signer_name = company.signer_name + " " + company.name
     
-    signer_name = u'ผู้จัดการแผนกทรัพยากรมนุษย์' + " " + company.name
-    if company.signer_name and company.signer_name != '':
-        signer_name = company.signer_name + " " + company.name
-    
-    if(config_letter):
-        letter_number = config_letter[0].letter_number
-        letter_date = config_letter[0].letter_date
+    if config_letter:
+        letter_number = config_letter.letter_number
+        letter_date = config_letter.letter_date
     else:
         letter_number = Configuration.objects.get(name="default.letter_number").value
         letter_date = Configuration.objects.get(name="default.letter_date").value
     except WorkDetail.DoesNotExist:
         work_detail = None
 
-    if work_detail:
+    if config_letter and config_letter.beginning_date!='':
+        letter_beginning_date = config_letter.beginning_date
+    elif work_detail:
         letter_beginning_date = work_detail.beginning_date
+    else:
+        letter_beginning_date = Configuration.objects.get(name="default.letter_beginning_date").value
+
+    if config_letter and config_letter.end_date!='':
+        letter_end_date = config_letter.end_date
+    elif work_detail:
         letter_end_date = work_detail.end_date
     else:
-        letter_beginning_date = Configuration.objects.get(name="default.letter_beginning_date").value
         letter_end_date = Configuration.objects.get(name="default.letter_end_date").value
-    eval_end_date = Configuration.objects.get(name="default.eval_end_date").value
+
+    if config_letter and config_letter.eval_date:
+        eval_end_date = config_letter.eval_date
+    else:
+        eval_end_date = Configuration.objects.get(name="default.eval_end_date").value
     
     if request.method=='POST':
         form = ConfigLetterForm(request.POST)
                 pass
             
             
-            if(config_letter):
-                config_letter[0].letter_number = letter_number
-                config_letter[0].letter_date = letter_date
-                config_letter[0].save()
-            else:
+            if not config_letter:
                 config_letter = ConfigLetter()
-                config_letter.company_id = company_id
-                config_letter.year = year_no
-                config_letter.letter_number = letter_number
-                config_letter.letter_date = letter_date
-                config_letter.save()
+
+            config_letter.company_id = company_id
+            config_letter.year = year_no
+            config_letter.letter_number = letter_number
+            config_letter.letter_date = letter_date
+            config_letter.signer_name = signer_name
+            config_letter.beginning_date = letter_beginning_date
+            config_letter.end_date = letter_end_date
+            config_letter.eval_date = eval_end_date
+            config_letter.save()
             
             return print_letter_pdf(company_id,
                                     year_no,
     
     return render_to_response("regis/company/conf_print_pdf.html",
                                   {'form':form,
+                                   'company': company,
                                    'company_id':company_id,
                                    'year_no':year_no,
                                    'currentpage':currentpage,}, 

regis/migrations/0065_auto__add_field_configletter_signer_name__add_field_configletter_begin.py

+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding field 'ConfigLetter.signer_name'
+        db.add_column('regis_configletter', 'signer_name', self.gf('django.db.models.fields.CharField')(default='', max_length=200), keep_default=False)
+
+        # Adding field 'ConfigLetter.beginning_date'
+        db.add_column('regis_configletter', 'beginning_date', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False)
+
+        # Adding field 'ConfigLetter.end_date'
+        db.add_column('regis_configletter', 'end_date', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False)
+
+        # Adding field 'ConfigLetter.eval_date'
+        db.add_column('regis_configletter', 'eval_date', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'ConfigLetter.signer_name'
+        db.delete_column('regis_configletter', 'signer_name')
+
+        # Deleting field 'ConfigLetter.beginning_date'
+        db.delete_column('regis_configletter', 'beginning_date')
+
+        # Deleting field 'ConfigLetter.end_date'
+        db.delete_column('regis_configletter', 'end_date')
+
+        # Deleting field 'ConfigLetter.eval_date'
+        db.delete_column('regis_configletter', 'eval_date')
+
+
+    models = {
+        'regis.announcement': {
+            'Meta': {'ordering': "['-created_at']", 'object_name': 'Announcement'},
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {}),
+            'file': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+        },
+        'regis.assignment': {
+            'Meta': {'object_name': 'Assignment'},
+            'company': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'assignments'", 'to': "orm['regis.Company']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'student': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'assignments'", 'to': "orm['regis.Student']"}),
+            'year': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'max_length': '5', 'null': 'True'})
+        },
+        'regis.company': {
+            'Meta': {'object_name': 'Company'},
+            'address': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}),
+            'contact_email': ('django.db.models.fields.EmailField', [], {'default': "''", 'max_length': '100', 'blank': 'True'}),
+            'contact_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
+            'fax_no': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100', 'null': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'short_description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
+            'short_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
+            'signer_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
+            'starting_char': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1'}),
+            'tel_no': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100', 'null': 'True'})
+        },
+        'regis.companystatusmarker': {
+            'Meta': {'object_name': 'CompanyStatusMarker'},
+            'company': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'markers'", 'to': "orm['regis.Company']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'year': ('django.db.models.fields.IntegerField', [], {})
+        },
+        'regis.conditions': {
+            'Meta': {'object_name': 'Conditions'},
+            'detail': ('django.db.models.fields.TextField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
+        },
+        'regis.configletter': {
+            'Meta': {'object_name': 'ConfigLetter'},
+            'beginning_date': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'}),
+            'company': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'config_letters'", 'to': "orm['regis.Company']"}),
+            'end_date': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'}),
+            'eval_date': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'letter_date': ('django.db.models.fields.DateField', [], {}),
+            'letter_number': ('django.db.models.fields.CharField', [], {'max_length': '300'}),
+            'signer_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '200'}),
+            'year': ('django.db.models.fields.IntegerField', [], {'max_length': '5'})
+        },
+        'regis.department': {
+            'Meta': {'object_name': 'Department'},
+            'code': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '3', 'null': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'name': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '100', 'null': 'True'}),
+            'short_name': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '10', 'null': 'True'}),
+            'short_name_for_letters': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '50', 'null': 'True'})
+        },
+        'regis.departmentnameinrequestletter': {
+            'Meta': {'object_name': 'DepartmentNameInRequestLetter'},
+            'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regis.Department']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name_to_be_requested': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'regis.education': {
+            'Meta': {'object_name': 'Education'},
+            'gpax': ('django.db.models.fields.FloatField', [], {}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'total_credit': ('django.db.models.fields.IntegerField', [], {}),
+            'upto_semester': ('django.db.models.fields.IntegerField', [], {}),
+            'upto_year': ('django.db.models.fields.IntegerField', [], {})
+        },
+        'regis.grade': {
+            'Meta': {'object_name': 'Grade'},
+            'course_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'}),
+            'course_number': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'credit': ('django.db.models.fields.IntegerField', [], {}),
+            'grade': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'regis_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}),
+            'student': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'grades'", 'to': "orm['regis.Student']"})
+        },
+        'regis.receipt': {
+            'Meta': {'object_name': 'Receipt'},
+            'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'company': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'receipts'", 'to': "orm['regis.Company']"}),
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'department': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'receipts'", 'to': "orm['regis.Department']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'num_accepted_students': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'num_rounds_shown': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+            'total_student': ('django.db.models.fields.IntegerField', [], {}),
+            'work_address': ('django.db.models.fields.TextField', [], {}),
+            'work_description': ('django.db.models.fields.TextField', [], {}),
+            'work_detail': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'receipts'", 'to': "orm['regis.WorkDetail']"}),
+            'year': ('django.db.models.fields.IntegerField', [], {'max_length': '5'})
+        },
+        'regis.status': {
+            'Meta': {'object_name': 'Status'},
+            'attended_orientation': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_registered': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'request_form_checkcode': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
+            'sent_request_form': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
+            'student': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'status'", 'to': "orm['regis.Student']"}),
+            'year': ('django.db.models.fields.IntegerField', [], {'max_length': '5'})
+        },
+        'regis.student': {
+            'Meta': {'object_name': 'Student'},
+            'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['regis.Department']", 'null': 'True'}),
+            'education': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['regis.Education']", 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+            'email': ('django.db.models.fields.EmailField', [], {'default': 'None', 'max_length': '100', 'null': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'intern_companies': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['regis.Company']", 'through': "orm['regis.Assignment']", 'symmetrical': 'False'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'prefix': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
+            'student_id': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+            'tel_no': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '50', 'null': 'True'})
+        },
+        'regis.workdetail': {
+            'Meta': {'object_name': 'WorkDetail'},
+            'beginning_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'company': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'workdetails'", 'to': "orm['regis.Company']"}),
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'dressing_description': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'other_description': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
+            'year': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'max_length': '5', 'null': 'True'})
+        }
+    }
+
+    complete_apps = ['regis']
     year = models.IntegerField(max_length=5,verbose_name=u'ปี')
     letter_number = models.CharField(max_length=300,verbose_name=u'เลขที่จดหมาย')
     letter_date = models.DateField(verbose_name=u'กำหนดวันที่ออกจดหมายราชการ')
-    
+    signer_name = models.CharField(max_length=200, default='')
+    beginning_date = models.CharField(max_length=100, default='')
+    end_date = models.CharField(max_length=100, default='')
+    eval_date = models.CharField(max_length=100, default='')
+
 
 class CompanyStatusMarker(models.Model):
     company = models.ForeignKey(Company, related_name='markers')
                     for m
                     in CompanyStatusMarker.objects.filter(year=year, number=number)])
 
-

regis/templates/regis/company/conf_print_pdf.html

 {% extends "regis/base.html" %}
 {% block content %}
-<h1 style="display:inline;">ตั้งค่าก่อนการพิมพ์ใบส่งตัว</h1>
+<h1 style="display:inline;">ตั้งค่าก่อนการพิมพ์ใบส่งตัว{{ company }}</h1>
 <div style="float: right">
   <a href="{% url regis_company_detail company_id %}" class="green small button">แสดงข้อมูลสถานประกอบการ</a>
   <a href="{% url regis_company_selection_stat %}" class="blue small button">กลับหน้าข้อมูลการเลือก</a>